Re:A bug in GCC that may cause memory leaks in valid C++ pro...
by mnarayan01 on Thursday April 27, 2017 @09:37PM
(#14216291)
I'm more talking about the exception behavior looking at e.g. https://wandbox.org/permlink/S5paK3Z9NpeCv3I0 (which exhibits the same bug). I mean you're right, and the fact that the User object is temporary should presumably not keep the first Resource destructor from firing, just it seems weird. I guess in my defense, apparently it seems weird to GCC as well.
[ Parent
| on HN ]
Re:A bug in GCC that may cause memory leaks in valid C++ pro...
by JonathonW on Friday April 28, 2017 @12:47AM
(#14216919)
The spec also explicitly addresses that (automatic objects' destructors must be called after an exception)-- see section 15.2 in the C++14 spec.
There is no ambiguity in the spec here; this is a GCC bug.