https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83945

            Bug ID: 83945
           Summary: internal compiler error: Segmentation fault with -O
                    -fcode-hoisting
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt.sexton at redlinetrading dot com
  Target Milestone: ---

This bug has been observed with MinGW-w64 on Fedora 27 (gcc 7.2.0).  It is not
observed with a native Linux compile on Fedora 27 (gcc 7.2.1).

$ cat bug.c
typedef struct {
  struct {
    int a[0]
  }
} b;
typedef struct { int c } d;
__thread d e;
f;
g() {
  b *h = &e.c;
  for (;;) {
    int *a = h->a;
    int i;
    for (; i; i--)
      j(a[f]);
    j(a[f]);
  }
}


$ x86_64-w64-mingw32-gcc -c -O -fcode-hoisting bug.c
bug.c:4:3: warning: no semicolon at end of struct or union
   }
   ^
bug.c:5:1: warning: no semicolon at end of struct or union
 } b;
 ^
bug.c:6:24: warning: no semicolon at end of struct or union
 typedef struct { int c } d;
                        ^
bug.c:8:1: warning: data definition has no type or storage class
 f;
 ^
bug.c:8:1: warning: type defaults to 'int' in declaration of 'f'
[-Wimplicit-int]
bug.c:9:1: warning: return type defaults to 'int' [-Wimplicit-int]
 g() {
 ^
bug.c: In function 'g':
bug.c:10:10: warning: initialization from incompatible pointer type
[-Wincompatible-pointer-types]
   b *h = &e.c;
          ^
bug.c:15:7: warning: implicit declaration of function 'j'
[-Wimplicit-function-declaration]
       j(a[f]);
       ^
bug.c:9:1: internal compiler error: Segmentation fault
 g() {
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.

$ x86_64-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info
--datadir=/usr/share --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose
--without-newlib --disable-multilib --disable-plugin --with-system-zlib
--disable-nls --without-included-gettext --disable-win32-registry
--enable-languages=c,c++,objc,obj-c++,fortran
--with-bugurl=http://bugzilla.redhat.com/bugzilla --with-cloog
--enable-threads=posix --enable-libgomp --target=x86_64-w64-mingw32
--with-sysroot=/usr/x86_64-w64-mingw32/sys-root
--with-gxx-include-dir=/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++
Thread model: posix
gcc version 7.2.0 20170814 (Fedora MinGW 7.2.0-1.fc27) (GCC) 

$ rpm -qf `which x86_64-w64-mingw32-gcc`
mingw64-gcc-7.2.0-1.fc27.x86_64

$ uname -a
Linux build-fedora27 4.14.6-300.fc27.x86_64 #1 SMP Thu Dec 14 15:31:24 UTC 2017
x86_64 x86_64 x86_64 GNU/Linux

Reply via email to