User account creation filtered due to spam.

Bug 10125 - [3.2/3.3/3.4 regression] Infinite loop caused by -O2
Summary: [3.2/3.3/3.4 regression] Infinite loop caused by -O2
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-03-17 23:46 UTC by mast
Modified: 2005-06-05 08:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mast 2003-03-17 23:46:01 UTC
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;
}
Comment 1 Wolfgang Bangerth 2003-03-22 04:57:44 UTC
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.
Comment 2 s.bosscher 2003-03-22 10:54:31 UTC
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
 
 
Comment 3 Richard Henderson 2003-03-23 02:57:36 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Not a bug.  Type-aliasing violation between "char **" and "unsigned **".
Comment 4 Richard Henderson 2003-03-23 11:41:11 UTC
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~
Comment 5 glen 2003-03-23 18:21:52 UTC
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

Comment 6 Andrew Pinski 2004-07-17 00:44:03 UTC
Reopening bug to mark as ...
Comment 7 Andrew Pinski 2004-07-17 00:44:17 UTC
Invalid.
Comment 8 Andrew Pinski 2005-06-05 08:51:34 UTC
Reopening to ...
Comment 9 Andrew Pinski 2005-06-05 08:51:50 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***