public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* GCC function call optimization error
@ 2003-11-16 21:34 Bryan Mills
0 siblings, 0 replies; only message in thread
From: Bryan Mills @ 2003-11-16 21:34 UTC (permalink / raw)
To: gcc-bugs
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
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
[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 355 bytes --]
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-11-16 21:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-16 21:34 GCC function call optimization error Bryan Mills
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).