This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c++/77312] Lambda that deletes itself accesses freed memory, but only if class is templated


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77312

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I don't see why you think this is valid thing to do.
> You are in a function which calls delete on the object you are in currently.
> That seems like this code is broken.

It's valid as long as nothing accesses any members of the class after it is
destroyed. When using code you don't control, such as std::function and a
lambda closure, you can't guarantee what it does or doesn't do with the memory.

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