gcc infloops with -O1 (but not -O, -Os, -O2, or -O3) given the following input.
Note that this happens using gcc built from svn a few hours ago, that it is
also reproducible with a two-day-old binary, but not with one from 2006-02-04.

$ cat xnanosleep.c
void
xnanosleep (_Bool overflow)
{
  struct { int tv_nsec; } ts_sleep;
  if (0 <= ts_sleep.tv_nsec)
    overflow |= 1;

  for (;;)
    {
      if (overflow)
        ts_sleep.tv_nsec = 0;
      if (foo (ts_sleep))
        break;
    }
}
$ time gcc -v -O1 xnanosleep.c 2> /t/err

gcc -v -O1 xnanosleep.c 2> /t/err  0.00s user 0.00s system 0% cpu 5.106 total
[Exit 130 (INT)]
$ cat /t/err
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /mirror/d/gcc/configure --disable-nls
--prefix=/p/p/gcc-2006-02-10.10h41 --disable-multilib --enable-languages=c
Thread model: posix
gcc version 4.2.0 20060210 (experimental)

/nobak/p/p/gcc-2006-02-10.10h41/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.2.0/cc1
-quiet -v -iprefix
/nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/
xnanosleep.c -quiet -dumpbase xnanosleep.c -mtune=generic -auxbase xnanosleep
-O1 -version -o /t/cc9XDV6L.s
ignoring nonexistent directory
"/nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory
"/p/p/gcc-2006-02-10.10h41/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/include"
ignoring nonexistent directory
"/p/p/gcc-2006-02-10.10h41/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/nobak/p/p/gcc-2006-02-10.10h41/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.2.0/include
 /usr/local/include
 /p/p/gcc-2006-02-10.10h41/include
 /usr/include
End of search list.
GNU C version 4.2.0 20060210 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.2.0 20060210 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: ddb06f39f2f5fb93ee768a85a3be125e


-- 
           Summary: new (within last few days) infinite loop with -O1
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: list+gcc-bugzilla at meyering dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to