This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50594] Option -fwhole-program discards replaced new operator for std::string
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Oct 2011 13:41:50 +0000
- Subject: [Bug c++/50594] Option -fwhole-program discards replaced new operator for std::string
- Auto-submitted: auto-generated
- References: <bug-50594-4@http.gcc.gnu.org/bugzilla/>
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.