This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 174728 - Simple test case that compiles wrong with gcc -O3
Simple test case that compiles wrong with gcc -O3
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-01 14:03 EST by Jonathan Kamens
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-12-06 11:51:47 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
test case (720 bytes, text/plain)
2005-12-02 09:07 EST, Jonathan Kamens
no flags Details

  None (edit)
Description Jonathan Kamens 2005-12-01 14:03:57 EST
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.
Comment 1 Jakub Jelinek 2005-12-02 04:17:57 EST
No testcase has been attached...
Comment 2 Jonathan Kamens 2005-12-02 09:07:24 EST
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.
Comment 3 Jakub Jelinek 2005-12-06 11:51:47 EST
The testcase is not valid C and is relying on undefined behaviour.
You get the result you are expecting at -O2 by pure luck.

Note You need to log in before you can comment on or make changes to this bug.