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]

[Bug optimization/11631] New: [3.3-hammer regression] zsh/kernel miscompilation


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11631

           Summary: [3.3-hammer regression] zsh/kernel miscompilation
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gbeauchesne at mandrakesoft dot com
                CC: aj at suse dot de,gcc-bugs at gcc dot gnu dot org,jh at
                    suse dot cz
  GCC host triplet: i686-pc-linux-gnu

The following program fails at -O2 but is OK at -Os. This occurs on both AMD64 &
 IA-32 but only on 3.3-hammer branch as of today. This is a regression from
3.3-hammer 2003/05/24. I believe this is similar to the kernel miscompilation
noticed by users at -O2 but zsh was easier to hunt. ;-)

Note the specific placement of f() & g(), the use of a static global variable,
the for(;;) loop.

/* Extracted from zsh sources.  */
/* Contributed by Gwenole Beauchesne <gbeauchesne@mandrakesoft.com>  */

extern void abort(void);
extern void exit(int);

static void f(const char *name);
static void g(const char *name);

static char *p;

int main(void)
{
  p = "foo";
  do {
      char *arg0 = p;
      if (!(p = strrchr(arg0, '/')))
	  p = arg0;
      else
	  p++;
      if (strcmp(p, "bar") != 0)
		break;
  } while (p);
  
  f(p);
  g(p);

  for (;;) {
  }

  return 0;
}

static void f(const char *name)
{
}

static void g(const char *name)
{
  if (name)
	exit(0);
  else
	abort();
}


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