public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106965] New: g++ optimization removes assigning 0 to deleted pointer- causes double free.
@ 2022-09-19 10:21 olddra3rd at mozmail dot com
  2022-09-19 11:29 ` [Bug c++/106965] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: olddra3rd at mozmail dot com @ 2022-09-19 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106965
           Summary: g++ optimization removes assigning 0 to deleted
                    pointer- causes double free.
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olddra3rd at mozmail dot com
  Target Milestone: ---

Created attachment 53590
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53590&action=edit
source file of the function implementations.

Dear GNU, how are you?
Using gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1) on a Ubuntu 22.04,
received a double free after using a destructor twice (one explicitly and one
at the end of function) with compiling optimizations..

Comp
Bug occurs when when the call happens on a different compilation unit:

int main()
{
 X x1;
 x1.~X();

 return 0;
}

From looking at the assembly - it seems assigning 0 to the pointer is removed
from the code.

Compilation flags:
g++ -O
Seems to work fine with clang++.

Have a great day!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-20 10:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 10:21 [Bug c++/106965] New: g++ optimization removes assigning 0 to deleted pointer- causes double free olddra3rd at mozmail dot com
2022-09-19 11:29 ` [Bug c++/106965] " rguenth at gcc dot gnu.org
2022-09-19 13:06 ` olddra3rd at mozmail dot com
2022-09-20  9:00 ` redi at gcc dot gnu.org
2022-09-20 10:02 ` olddra3rd at mozmail dot com
2022-09-20 10:18 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).