This is the mail archive of the
mailing list for the libstdc++ project.
Re: correct transformations gcc 3.2
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:
> 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.