[Bug libstdc++/65434] Memory leak in pool constructor
lopresti at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 15 17:55:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65434
Patrick J. LoPresti <lopresti at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lopresti at gmail dot com
--- Comment #5 from Patrick J. LoPresti <lopresti at gmail dot com> ---
Seems pretty sloppy not to free what you allocate, and then demand all leak
checking tools forever work around the sloppiness... Even if you are the
runtime.
Couldn't you fix this by using the init_priority attribute on emergency_pool?
Alternatively, do like any application would and use a Meyers singleton instead
of a global variable? Like so:
namespace {
pool &emergency_pool()
{
static pool emp;
return emp;
}
}
Since destructors always run in the opposite order of construction, you would
just need to make sure you obtain the first reference early enough.
More information about the Gcc-bugs
mailing list