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]

GCC function call optimization error


I am using GCC 3.2.1 for an Operating Systems course at CMU;
We're using a lot of inline assembly, and I discovered some flagrantly incorrect GCC output in argument passing for functions.
Specifically, writing arguments before function calls is apparently not flagged to rely on the value of %esp.


Please see the attached almost-minimal test-case for an example.


Bryan Mills
void foo(int bar)
{
}

int main()
{
    int returnCode;
    
    foo(-1); /* not broken */
    asm volatile("pushl $0" : : : "esp"); /* put a 0 on the stack */
    foo(-1); /* broken -- should not overwrite value just placed on stack */
    asm volatile("popl %0" : "=r" (returnCode) : : "esp"); /* should be 0, actually 1 */
    
    exit(returnCode);
}

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