Placement new destructor call optimized out

Bug #1577891 reported by Jeff Curless
12
This bug affects 2 people
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~14.04.1) 4.8.4,
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:000102030405060708090a0b0c0d0e0f10111213
After :0000000000000000000000000000000000000000

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:000102030405060708090a0b0c0d0e0f10111213
After :000102030405060708090a0b0c0d0e0f10111213

Tags: xenial
Revision history for this message
Jeff Curless (jeff-curless) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gcc-5 (Ubuntu):
status: New → Confirmed
Changed in gcc-5 (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Matthias Klose (doko) wrote :

closing as invalid.

Changed in gcc-5 (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.