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]

[Bug target/52670] New: -mabi=ms generates bad code


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

             Bug #: 52670
           Summary: -mabi=ms generates bad code
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dg@cowlark.com


If I take this test case:

  int z(int i) { return i; }

...and compile it with:

  gcc-4.6 -Os -m32 -mabi=sysv -o test.s -c test.c -S -fomit-frame-pointer

...I get this (trimmed):

    movl    4(%esp), %eax
    ret

However, if I compile it with this:

  gcc-4.6 -Os -m32 -mabi=ms -o test.s -c test.c -S -fomit-frame-pointer

...then I get this, which is wrong:

    movl    36(%esp), %eax
    ret

Compiling with a copy of the Mingw compiler or with Visual C produces (the
equivalent of) the 4 result. The -fomit-frame-pointer is there purely to reduce
the size of the output; the bug persists without it. This appears to affect all
stack accesses. It *seems* to only apply to ia32 code. amd64 code appears to be
fine, but my target environment is ia32 only so I haven't looked into amd64
much.

This was discussed on gcc-help here:

  http://gcc.gnu.org/ml/gcc-help/2012-03/msg00281.html

This patch appears to fix the issue:

  http://gcc.gnu.org/ml/gcc-patches/2011-03/txt00118.txt

(although the patch needs a bit of work to apply).


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