Placement new destructor call optimized out
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc |
Unknown
|
Unknown
|
|||
gcc-5 (Ubuntu) |
Invalid
|
Medium
|
Unassigned |
Bug Description
We have a template class that we are using with placement new. Code works fine in g++ (Ubuntu 4.8.4-2ubuntu1~
however in g++ (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413, the destructor call is optimized out, even though we explicitly call it.
I have attached sample code (reduced down from our project) to show the issue. If we add a NON-POD data type, everything works
fine... this however is not an option for our project, as in our environment this is normally a packed class, though the example fails
either way.
This works:
g++ -O0 -g -ggdb test.cpp -o test0
./test0
Before:
After :00000000000000
These do not:
g++ -O1 -g -ggdb test.cpp -o test1
g++ -O2 -g -ggdb test.cpp -o test2
g++ -O3 -g -ggdb test.cpp -o test3
./test1
Before:
After :00010203040506
Changed in gcc-5 (Ubuntu): | |
importance: | Undecided → Medium |
Status changed to 'Confirmed' because the bug affects multiple users.