https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77268
Bug ID: 77268 Summary: Vector erase call destructor for last element twice and doesn't call destructor for eased element. Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jdinardo at nycap dot rr.com Target Milestone: --- Created attachment 39465 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39465&action=edit Small 33 line program which shows the problem. Vector erase is asked to erase 3rd element of 5 element vector. The destructor for the last(fifth) element is called twice and the destructor for the 3rd element is not called. The 3rd element is erased but the malloced memory is never freed. BUG 47305 seems to imply that this is ok. If that is the case, then pleas ignore this. VERSION - g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/li Thread model: posix gcc version 6.1.1 20160802 (GCC) System is Arch Linux MAKEFILE CPPFLAGS=-g -Wall -lfltk ALL:hello t1 v1 MAKEFILE OUTPUT - no warnings or errors g++ -g -Wall -lfltk v1.cc -o v1 COMMAND LINE v1 SMALL 33 LINE TEST PROGRAM Included as attachment