[Bug libstdc++/64504] Invalid free() with _GLIBCXX_DEBUG and -fwhole-program
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jan 26 11:06:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64504
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrey Vihrov from comment #2)
> , and there is no warning without -fwhole-program. Of course, I can get the
> same effect by making everything "static", but this depends on me
> remembering to do it, so this option is better in this regard. -flto doesn't
> have the same effect.
This is not what -fwhole-program is for, you're just using it for a side-effect
that happens as a result of making everything static.
So my suggestion would be "don't do that".
If you have a single file how hard can it be to remember to make your globals
static? How many of them do you have?! Just enclosing them in an anonymous
namespace would work, and then all you have to remember to do is add new
globals inside that scope, not elsewhere in the file.
More information about the Gcc-bugs
mailing list