我有一个struct alignedStruct
,它需要特殊对齐(见分机):
void* operator new(size_t i) { return _aligned_malloc(i, 16); }
void operator delete(void* p) { _aligned_free(p); }
这种对齐方式适用于 的唯一对象/指针alignedStruct
,但后来我尝试这样做:
alignedStruct * arr = new alignedStruct[count];
我的应用程序崩溃了,问题肯定是关于“数组对齐”(正好在上一行):
0xC0000005: Access violation reading location 0xFFFFFFFF.
这种崩溃发生在约 60% 的时间,也表明问题不典型。