This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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:
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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]