0

我有以下简化代码:

struct sMatch
{
   public:
      sMatch( ULONG size )
      {
         myVector.assign( size, false );
      }
      std::vector< bool > myVector;
}

std::vector< sMatch > myMatchVector;
sMatch temp( 3 );
myMatchVector.push_back( temp );

执行 push_back() 时,我会定期看到信号 7 (SIGBUS)、代码 1 (BUS_ADRALN)崩溃。Backtrace 在 + 运算符中指向myVector,但我不清楚实现有什么问题。

我一直在为 sMatch 构造函数中的 myVector 尝试不同的实现/内存分配,我的尝试都没有成功防止这种崩溃。

4

1 回答 1

1

Without knowing what else is going on, it's hard to say, but I recently ran into a problem with dynamically allocated members of one class being written outside their bounds and overwriting the members of another class.

Which is to say, it seems possible that the address alignment error is because something else is overwriting your vector.

Again, a more complete example is probably the next step... unless you ARE getting that error with THIS example...

于 2013-11-05T19:40:32.220 回答