Bug 188649 - optimization changes expression semantics
Summary: optimization changes expression semantics
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 188327
TreeView+ depends on / blocked
 
Reported: 2006-04-12 00:10 UTC by Shahms E. King
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version: 4.1.0-7
Clone Of:
Environment:
Last Closed: 2006-04-12 08:53:55 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Test case demonstrating gcc optimization bug (1.05 KB, text/plain)
2006-04-12 00:10 UTC, Shahms E. King
no flags Details

Description Shahms E. King 2006-04-12 00:10:58 UTC
Description of problem:
Compiling the attached test case with optimization causes the while loop to exit
after only one iteration, rather than 81 iterations.  Compiling without
optimization uses the proper number of iteration.  Additionally, the subsequent
assert on the negative loop condition also "succeeds" despite the fact that the
subsequent, semantically equivalent, assertion fails.  Printing the loop
condition also shows that it is still true, despite the loop having exited.

While the code prior to the loop involves some odd casts, it's all standard C
and the loop itself is purely standard C, requiring only comparisons between
pointers that point to elements of the same array. This is particularly bad as
this test case was adapted from the python integer block allocator and causes it
to allocate a block of 82 ints, but only use one of them leading to huge memory
leaks.


Version-Release number of selected component (if applicable):
gcc-4.1.0-3

How reproducible:
Always

Steps to Reproduce:
1. gcc -O test_gcc.c -o test_gcc
2../test_gcc
3. Abort on assertion that should be true 
  
Actual results:
The loop is executed once and exits while the guard condition is true.

Expected results:
The loop is executed 81 times, and only exits once the guard condition is false.


Additional info:

Comment 1 Shahms E. King 2006-04-12 00:10:58 UTC
Created attachment 127643 [details]
Test case demonstrating gcc optimization bug

Comment 2 Jakub Jelinek 2006-04-12 08:53:55 UTC
Fixed in gcc-4.1.0-7 in rawhide.

Comment 3 Jeremy Katz 2006-04-26 17:01:21 UTC
Jakub -- any chance of pushing the fix into fc5-updates so we can build an
updated python?


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