The attached module, when compiled with -O2, has wrong code generated for the
last set_global_field call. The assembly shows:

        leal    4(%edx), %eax
        cmpl    marked_limit, %eax
        movl    BadArguments, %ecx
        movl    $record_12420+4, (%edx)
        movl    %eax, marked_top
        jbe     .L28
        movl    %ecx, record_12420+4
        call    gc
.L28:
        leave
        xorl    %eax, %eax
        ret

while the assignment of BadArguments (from %ecx) to record_12420+4 should be
performed unconditionally, as can be easily deduced from the source.

This is gcc-4.2.0-0.20060806r115974. The bug doesn't manifest without -O2 or
when the number of set_global_field calls is reduced.


-- 
           Summary: Wrong code generated (assignment incorrectly optimized
                    out)
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qrczak at knm dot org dot pl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to