Bug 49223 - Internal compiler error when using OpenMP
Summary: Internal compiler error when using OpenMP
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2011-05-29 09:48 UTC by Thanassis Tsiodras
Modified: 2011-06-01 11:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-30 11:55:00


Attachments
Preprocessed output from input C++ file that triggers the bug. (106.34 KB, application/x-bzip)
2011-05-29 09:48 UTC, Thanassis Tsiodras
Details
gcc46-pr49223.patch (961 bytes, patch)
2011-05-30 11:56 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thanassis Tsiodras 2011-05-29 09:48:03 UTC
Created attachment 24391 [details]
Preprocessed output from input C++ file that triggers the bug.

When using -fopenmp, compiling my open source renderer ( http://users.softlab.ece.ntua.gr/~ttsiod/renderer.html ) triggers an internal compiler error. This did not happen with previous versions of GCC (I've added OpenMP support and seen it work fine since GCC 4.3.2). 

bash$ make
...
g++ -DHAVE_CONFIG_H -I.  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -I./../lib3ds-1.3.0/ -fopenmp  -O3 -g -Wall -Wextra -fomit-frame-pointer -ffast-math -funsafe-math-optimizations -mtune=native -msse -mrecip -mfpmath=sse -msse2 -mssse3 -DNDEBUG -MT renderer-Rasterizers.o -MD -MP -MF .deps/renderer-Rasterizers.Tpo -c -o renderer-Rasterizers.o `test -f 'Rasterizers.cc' || echo './'`Rasterizers.cc
Rasterizers.cc: In member function 'void RasterizeScene<TriangleCarrier>::DrawTriangles(int, int) const':
Rasterizers.cc:250:100: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.

I attach the preprocessed output that easily reproduces the bug. With -fopenmp, the compiler crashes:

    bash$ g++ -c -fopenmp  -O3 -g -Wall -Wextra -fomit-frame-pointer -ffast-math -funsafe-math-optimizations -mtune=native -msse -mrecip -mfpmath=sse -msse2 -mssse3 renderer-Rasterizers.i

...without it, it works:

    bash$ g++ -c -O3 -g -Wall -Wextra -fomit-frame-pointer -ffast-math -funsafe-math-optimizations -mtune=native -msse -mrecip -mfpmath=sse -msse2 -mssse3 renderer-Rasterizers.i

Version of GCC (g++ -v):

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /build/src/gcc-4.6-20110513/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --disable-multilib --disable-libstdcxx-pch --enable-checking=release
Thread model: posix
gcc version 4.6.0 20110513 (prerelease) (GCC) 

System Type (uname -a):

Linux home 2.6.38-ARCH #1 SMP PREEMPT Fri May 13 07:54:18 UTC 2011 i686 Intel(R) Celeron(R) CPU E3400 @ 2.60GHz GenuineIntel GNU/Linux

Kind regards,
Thanassis Tsiodras, Dr.-Ing.
Comment 1 Jakub Jelinek 2011-05-30 11:56:18 UTC
Created attachment 24394 [details]
gcc46-pr49223.patch

Untested fix.  The problem is that require_complete_type is just a nop if
processing_template_decl, so we can't rely on the type being actually complete.
Comment 2 Jakub Jelinek 2011-05-30 12:16:08 UTC
Author: jakub
Date: Mon May 30 12:16:04 2011
New Revision: 174432

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174432
Log:
	PR c++/49223
	* semantics.c (finish_omp_clauses): Call require_complete_type
	even for copyin/copyprivate clauses.  Only call
	cxx_omp_create_clause_info if inner_type is COMPLETE_TYPE_P.

	* g++.dg/gomp/pr49223-1.C: New test.
	* g++.dg/gomp/pr49223-2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr49223-1.C
    trunk/gcc/testsuite/g++.dg/gomp/pr49223-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jakub Jelinek 2011-05-30 12:19:02 UTC
Author: jakub
Date: Mon May 30 12:18:59 2011
New Revision: 174433

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174433
Log:
	PR c++/49223
	* semantics.c (finish_omp_clauses): Call require_complete_type
	even for copyin/copyprivate clauses.  Only call
	cxx_omp_create_clause_info if inner_type is COMPLETE_TYPE_P.

	* g++.dg/gomp/pr49223-1.C: New test.
	* g++.dg/gomp/pr49223-2.C: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/gomp/pr49223-1.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/gomp/pr49223-2.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/semantics.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 4 Jakub Jelinek 2011-06-01 11:08:38 UTC
Fixed.