Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 57574 - gcc 3.1-0.10 bad code for switch statement with -O
gcc 3.1-0.10 bad code for switch statement with -O
Product: Red Hat Raw Hide
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2001-12-16 04:34 EST by Valdis Kletnieks
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-12-19 12:35:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
z9.i.gz file - test case. gunzip, then 'gcc -O -c z9.i' (38.87 KB, application/octet-stream)
2001-12-16 04:35 EST, Valdis Kletnieks
no flags Details

  None (edit)
Description Valdis Kletnieks 2001-12-16 04:34:05 EST
Description of Problem: gcc -O generates bad code for switch statement

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

How Reproducible: 'gcc -O -c z9.i' with attached z9.i - the switch
statement in pdump_get_indirect_count is miscompiled with -O, generating an
undefined reference to a label in a branch table.

Steps to Reproduce:
1. unzip z9.i.gz
2. gcc -v -c z9.i  and then 'nm z9.o | grep L'  - none found.
3. gcc -V -O3 -c z9.i  and 'mn z9.o | grep L'

Actual Results: -O, -O1, -O2, and -O3 all miscompile the switch statement,
leaving a dangling '.long .L<n>' for varying values of <N> depending on the
-O level.  This results in an undefined symbol when you try to link the

Expected Results: Correct code generated.

Additional Information:
I have attached a 'z9.i.gz' file - unzip and compile as above.
Comment 1 Valdis Kletnieks 2001-12-16 04:36:00 EST
Created attachment 40767 [details]
z9.i.gz file - test case. gunzip, then 'gcc -O -c z9.i'
Comment 2 Jakub Jelinek 2001-12-19 12:35:43 EST
See http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02108.html
Comment 3 Jakub Jelinek 2001-12-31 05:24:00 EST
Should be fixed in gcc-3.1-0.11.

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