correct transformations gcc 3.2

Jonathan Wakely cow@compsoc.man.ac.uk
Tue Jul 8 12:36:00 GMT 2003


On Tue, Jul 08, 2003 at 07:29:15PM +1000, Adrian Sheppard wrote:

> The problem is that "up" and "down" hold references to
> temporary objects, namely the locales.  The storage for these temporaries
> is released immediately after construction of up and down, so up.loc and
> down.loc end up pointing to memory that's waiting to be reused.

The example in the latest docs uses a local (non-temporary) locale object,
so it isn't destroyed before it's used. The fixed version is here:
http://gcc.gnu.org/onlinedocs/libstdc++/22_locale/howto.html#7

> I was under the impression that gcc warned about references to
> temporaries, but I must be wrong.

IIRC it warns about functions returning references to temporaries, but
not references to temporaries in general, which are not always bad.

jon




More information about the Libstdc++ mailing list