static_cast静态类型转换指针导致Release程序随机崩溃报错
static_cast静态类型转换指针导致崩溃报错
核心代码如下:
typedef struct A1 { char pos[4]; }A; typedef struct B1 { char zoom[4]; char pos[8]; } B; int main() { A* a1 = new A; B* b1 = static_cast<B*> a1; for(int i = 0; i < 8; ++i) { b1->pos[i] = 0; } }