This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54027] New: possible mis-optimization of signed left shift in c89 mode
- From: "regehr at cs dot utah.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Jul 2012 04:24:00 +0000
- Subject: [Bug c/54027] New: possible mis-optimization of signed left shift in c89 mode
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54027
Bug #: 54027
Summary: possible mis-optimization of signed left shift in c89
mode
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: regehr@cs.utah.edu
The program below is clearly undefined in C99, but I'm not sure that it should
be undefined in C89 mode.
GCC pre-4.8.0 turns the code into an infinite loop even in C89 mode at -O2 and
higher.
regehr@home:~/svn/code$ cat shift.c
int main (void)
{
int x = 1;
while (x)
x <<= 1;
return x;
}
regehr@home:~/svn/code$ gcc -O2 -std=c89 shift.c ; ./a.out
^C
regehr@home:~/svn/code$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/regehr/z/compiler-install/gcc-r189449-install/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/regehr/z/compiler-source/gcc/configure
--with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r189449-install
--enable-languages=c,c++
Thread model: posix
gcc version 4.8.0 20120713 (experimental) (GCC)