libstdc++/1072: Exception-unsafe code in locale
Petter Reinholdtsen
pere@hungry.com
Sun May 27 04:26:00 GMT 2001
The following reply was made to PR libstdc++/1072; it has been noted by GNATS.
From: Petter Reinholdtsen <pere@hungry.com>
To: peturr@usa.net
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/1072: Exception-unsafe code in locale
Date: Sun, 27 May 2001 13:19:26 +0200
Here are a few comments from a simple gcc user.
I checked the current source in CVS and compared it to the code in
your bug report, and the code is different now.
> These catch blocks are useless since the target pointers are never
> modified if either operator new or the constructors throw an
> exception.
I believe this is correct. The try/catch block is completely useless,
and it would be better to use auto_ptr.
> In fact, they will probably cause a crash since the pointers are not
> initialized before the try block.
This seem to be correct with gcc 2.95.2, but the C++ standard
specifies the pointer member variables should be initialized to
0. (Read clause 12.6.2, 8.5 and 3.9 to learn more).
> Also, if an exception is thrown from the second try block, the
> object allocated in the first one is leaked.
This is correct, but seem to have been fixed.
--
##> Petter Reinholdtsen <## | pere@hungry.com
More information about the Gcc-prs
mailing list