Will unused deconstructors be optimized out?
- by Brendan Long
Assuming MyClass uses the default deconstructor (or no deconstructor), and this code:
MyClass buffer[] = new MyClass[i];
// Construct N objects using placement new
for(size_t i = 0; i < N; i++){
~buffer[i];
}
delete[] buffer;
Is there any optimizer that would be able to remove this loop?
Also, is there any way for my code to detect if…