Bug 174728 - Simple test case that compiles wrong with gcc -O3
Summary: Simple test case that compiles wrong with gcc -O3
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc   
(Show other bugs)
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-12-01 19:03 UTC by Jonathan Kamens
Modified: 2007-11-30 22:11 UTC (History)
0 users

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


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

Description Jonathan Kamens 2005-12-01 19:03:57 UTC
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 09:17:57 UTC
No testcase has been attached...

Comment 2 Jonathan Kamens 2005-12-02 14:07:24 UTC
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 16:51:47 UTC
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.