public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/51353] New: GCC incorrectly optimizes away assignment to return address
@ 2011-11-30  9:14 nkeynes at deadcoderemoval dot net
  2011-12-14 23:29 ` [Bug rtl-optimization/51353] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nkeynes at deadcoderemoval dot net @ 2011-11-30  9:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51353

             Bug #: 51353
           Summary: GCC incorrectly optimizes away assignment to return
                    address
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nkeynes@deadcoderemoval.net


In the following code, GCC with -O completely removes the if block and
assignment:

int foo( int arg, void *exc )
{
    if( arg < 2 ) {
        *(((void **)__builtin_frame_address(0))+1) = exc;
    }
    return 0;
}

Producing (for i386):
.globl _foo
_foo:
    pushl    %ebp
    movl    %esp, %ebp
    movl    $0, %eax
    popl    %ebp
    ret

The relative merits and portability of the code aside, it doesn't seem correct
to completely remove the assignment. 

The code was compiled correctly with gcc 4.2.4, and fails with 4.4.6, 4.5.3,
and 4.6.1. The generated code is also correct with all optimizations off when
compiled with any of these versions.


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

end of thread, other threads:[~2012-01-04  0:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30  9:14 [Bug rtl-optimization/51353] New: GCC incorrectly optimizes away assignment to return address nkeynes at deadcoderemoval dot net
2011-12-14 23:29 ` [Bug rtl-optimization/51353] " pinskia at gcc dot gnu.org
2011-12-15  2:16 ` nkeynes at deadcoderemoval dot net
2012-01-04  0:38 ` pinskia 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).