This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/7289: wrong code generated for switch statement


>Number:         7289
>Category:       c
>Synopsis:       wrong code generated for switch statement
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 12 12:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Marc Paterno
>Release:        gcc version 3.1
>Organization:
>Environment:
gcc -v
Reading specs from /home/cdfsoft/products/gcc/v3_1/Linux+2/lib/gcc-lib/i686-pc-l
inux-gnu/3.1/specs
Configured with: ../../gcc-3.1/configure --prefix=/tmp/build-gcc-v3_1 --disable-
shared --with-gnu-ld --with-ld=/tmp/build-gcc-v3_1/bin/ld --with-gnu-as --with-a
s=/tmp/build-gcc-v3_1/bin/as --enable-threads=posix
Thread model: posix
gcc version 3.1
>Description:
The generated object file contains an unresolved symbol
which should not exist. The symbol is generated because
of the mishandling of a assembler statement label.

The problem only appears when all these conditions are met:
1) optimization level is -O0
2) the enum has at least 5 elements
3) all non-default branches of the switch return the same
value
4) the default branch of the switchs either returns the
same value OR is known not to return (either it calls
a function marked as "noreturn", or, in C++, it throws).
>How-To-Repeat:
Compile with 
  gcc -O0 -c bad.i
>Fix:
If any level of optimization greater than 0 is used,
the problem does not appear.

If the default statement calls a function which the
compiler can't tell will not return, the problem does
not appear.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]