This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/5006: Multiple temporary objects created on stack in the same location.
- From: richard at ex-parrot dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 4 Dec 2001 11:16:01 -0000
- Subject: optimization/5006: Multiple temporary objects created on stack in the same location.
- Reply-to: richard at ex-parrot dot com
>Number: 5006
>Category: optimization
>Synopsis: Multiple temporary objects created on stack in the same location.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Tue Dec 04 03:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Richard Smith
>Release: 3.0.2 (and 3.0.1)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
When compiling with -O, the compiler creates a temporary object of type auto_ptr<A> on the stack. It then overwrites this with a temporary of type A before calling the destructor on the original auto_ptr<A>. This tries to call ::operator delete() on what it thinks is the heap-allocated pointer owned by the auto_ptr but is actually a string literal owned by A. Depending on the exact memory layout, a segv sometimes results.
>How-To-Repeat:
Build with -O to duplicate the bug. A run-time segv (usually) results.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: