The attached program yields the expected results when compiled with "gcc", "gcc -O", and "gcc -O2": jik2:/tmp!568$ gcc -O2 test.c jik2:/tmp!569$ ./a.out format=Foo %s bar, first arg=baz However, it yields different results when compiled with "gcc -O3": jik2:/tmp!570$ gcc -O3 test.c test.c: In function øformat1ù: test.c:32: warning: passing argument 3 of ødoprntù makes pointer from integer w\ ithout a cast test.c:32: warning: passing argument 6 of ødoprntù from incompatible pointer ty\ pe test.c: In function ømainù: test.c:37: warning: passing argument 1 of øformat1ù makes integer from pointer \ without a cast test.c:32: warning: passing argument 3 of ødoprntù makes pointer from integer w\ ithout a cast test.c:32: warning: passing argument 6 of ødoprntù from incompatible pointer ty\ pe jik2:/tmp!571$ ./a.out format=Foo %s bar, first arg= I believe this is causing a coredump in Emacs, about which I shall soon file a second bug report. gcc-4.0.2-6, emacs-21.4-10.
No testcase has been attached...
Created attachment 121752 [details] test case Sorry, here it is. Incidentally, this is still an issue, but I'm wrong about it being the cause of the emacs coredump. That's actually being caused by -fstack-protector.
The testcase is not valid C and is relying on undefined behaviour. You get the result you are expecting at -O2 by pure luck.