Switch gets optimized away incorrectly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-defaults (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
A program stub with a very simple switch statement is performing incorrectly; examination of the assembler output shows that the switch has been partially optimized away, leaving only the default case, when a different case would be expected to execute.
This occurs in lucid (gcc-4.4) and natty (gcc-4.5.2), but I'm reporting it as a 4.4 bug because I mostly use lucid.
I expected the program to copy stdin to stdout, one character at a time. Instead, it fails on the first character, executing statements that I have in the default: case. These statements show that the switch expression should have chosen a different case, but that case is not even compiled into the assembler code.
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: gcc 4:4.4.3-1ubuntu1
ProcVersionSign
Uname: Linux 2.6.32-34-generic i686
Architecture: i386
Date: Tue Oct 11 20:31:22 2011
InstallationMedia: Ubuntu 10.04.1 LTS "Lucid Lynx" - Release i386 (20100816.1)
ProcEnviron:
LANGUAGE=en_US:en
PATH=(custom, user)
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: gcc-defaults
This version has expired some times ago, and no backport is expected as there is no 'security' reported problem