Description of Problem: gcc -O generates bad code for switch statement Version-Release number of selected component (if applicable): gcc-3.1-0.10 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 program. Expected Results: Correct code generated. Additional Information: I have attached a 'z9.i.gz' file - unzip and compile as above.
Created attachment 40767 [details] z9.i.gz file - test case. gunzip, then 'gcc -O -c z9.i'
See http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02108.html
Should be fixed in gcc-3.1-0.11.