The supplied program doesn't terminate with -O2. It works correctly without optimization, with -O and with -O3. It's a regression since gcc 2.95.4. Release: gcc version 3.2.3 20030309 (Debian prerelease) Environment: Linux 2.4.20, i686, libc 2.3.1 Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux Thread model: posix How-To-Repeat: Compile the following using "gcc -O2 bug.c". The resulting binary doesn't terminate when run. int *foo (void) __attribute__ ((__const)); int *foo (void) { static int arr[] = {1, 0}; return arr; } int main() { signed char *c = "\0\1"; signed char **s = &c; while (foo()[**(unsigned char **)s] & 1) ++*s; }
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. A regression in 3.2/3.3/3.4 w.r.t. 2.95. Was broken sometime between 2.95 and 3.0. W.
From: Steven Bosscher <s.bosscher@student.tudelft.nl> To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, mast@lysator.liu.se, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: optimization/10125: [3.2/3.3/3.4 regression] Infinite loop caused by -O2 Date: Sat, 22 Mar 2003 10:54:31 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10125 The loop does terminate if I compile with "-O2 -fno-strict-aliasing" on i586-pc-linux-gnu. The only differences in the .00.rtl dumps are changes like this (- = -O2, + = -O2 -fno-strict-aliasing): (insn 27 26 28 (nil) (set (reg/f:SI 66) - (mem:SI (reg/v/f:SI 63) [6 S4 A32])) -1 (nil) + (mem:SI (reg/v/f:SI 63) [0 S4 A32])) -1 (nil) (nil)) Greetz Steven
State-Changed-From-To: analyzed->closed State-Changed-Why: Not a bug. Type-aliasing violation between "char **" and "unsigned **".
From: Richard Henderson <rth@redhat.com> To: Glen Nakamura <glen@imodulo.com> Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rth@gcc.gnu.org Subject: Re: optimization/10125: [3.2/3.3/3.4 regression] Infinite loop caused by -O2 Date: Sun, 23 Mar 2003 11:41:11 -0800 On Sun, Mar 23, 2003 at 06:21:52PM +0000, Glen Nakamura wrote: > > Not a bug. Type-aliasing violation between "char **" and "unsigned **". > > Actually, the test case uses "signed char **" and "unsigned char **"... > Not sure if that changes your analysis. No; the former was just a typo. r~
From: Glen Nakamura <glen@imodulo.com> To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rth@gcc.gnu.org Cc: Subject: Re: optimization/10125: [3.2/3.3/3.4 regression] Infinite loop caused by -O2 Date: Sun, 23 Mar 2003 18:21:52 +0000 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10125 > State-Changed-From-To: analyzed->closed > State-Changed-By: rth > State-Changed-When: Sun Mar 23 02:57:36 2003 > State-Changed-Why: > Not a bug. Type-aliasing violation between "char **" and "unsigned **". Actually, the test case uses "signed char **" and "unsigned char **"... Not sure if that changes your analysis. - glen
Reopening bug to mark as ...
Invalid.
Reopening to ...
Mark as a dup of bug 21920. *** This bug has been marked as a duplicate of 21920 ***