[Bug c++/50594] Option -fwhole-program discards replaced new operator for std::string

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Oct 3 13:42:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50594

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-10-03 13:41:50 UTC ---
(In reply to comment #3)
> Thank you for the replies. Is this behaviour standard-conforming?

The documentation for -fwhole-program says that all functions become static,
which I suspect makes your new and delete operators invalid for replacement
functions.  Andrew's suggestion works, just add these declarations:

void * operator new(std::size_t n) throw(std::bad_alloc)
__attribute__((externally_visible));
void operator delete(void * p) throw() __attribute__((externally_visible));

That prevents -fwhole-program from making them static.



More information about the Gcc-bugs mailing list