Bug 188649 - optimization changes expression semantics
optimization changes expression semantics
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
Blocks: 188327
  Show dependency treegraph
Reported: 2006-04-11 20:10 EDT by Shahms E. King
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version: 4.1.0-7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-04-12 04:53:55 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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

  None (edit)
Description Shahms E. King 2006-04-11 20:10:58 EDT
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

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

How reproducible:

Steps to Reproduce:
1. gcc -O test_gcc.c -o 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-11 20:10:58 EDT
Created attachment 127643 [details]
Test case demonstrating gcc optimization bug
Comment 2 Jakub Jelinek 2006-04-12 04:53:55 EDT
Fixed in gcc-4.1.0-7 in rawhide.
Comment 3 Jeremy Katz 2006-04-26 13:01:21 EDT
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.