标签: c++ new-operator undefined-behavior
以下代码是否导致未定义的行为?我从不直接或间接调用T的构造函数。
struct T { void sample() { } int *a; int *b; }; int main() { T* ptr = reinterpret_cast<T*>(operator new(sizeof(T))); ptr->a = new int(1); ptr->b = new int(2); ptr->sample(); delete ptr; }