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]

optimization/5006: Multiple temporary objects created on stack in the same location.



>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:


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