[Bug c/11772] Incorrect code generated with -mrtd and long long

mikulas at artax dot karlin dot mff dot cuni dot cz gcc-bugzilla@gcc.gnu.org
Sat Aug 2 17:17:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


mikulas at artax dot karlin dot mff dot cuni dot cz changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |


------- Additional Comments From mikulas at artax dot karlin dot mff dot cuni dot cz  2003-08-02 17:17 -------
This is test code for the bug:

long long __divdi3(long long a, long long b)
{
        return a + b;
}

f()
{
        volatile int x = 1;
        long long a1 = 4, a2 = 2;
        /*long long a = __divdi3(a1, a2);*/
        long long a = a1 / a2;
        if (x != 1) abort();
        return a;
}

main()
{
        return f();
}

compile it with -fomit-frame-pointer -mrtd flags. When you run it, it fails in Abort function, because value of variable `x' changed because stack pointer is incorrect in function f.

When you look at assembler, you see that __divdi3 exits with ret $16 and there's additional addl $16, %esp after calling __divdi3.

Mikulas



More information about the Gcc-bugs mailing list