This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GCC function call optimization error
- From: Bryan Mills <bmills at andrew dot cmu dot edu>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 16 Nov 2003 16:35:15 -0500
- Subject: 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);
}