Bug 60807 - internal compiler error (basic_string.tcc)
Summary: internal compiler error (basic_string.tcc)
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-10 10:10 UTC by Thomas Klausner
Modified: 2014-04-11 14:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-04-11 00:00:00


Attachments
Result of -save-temps (75.29 KB, application/gzip)
2014-04-10 10:10 UTC, Thomas Klausner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Klausner 2014-04-10 10:10:51 UTC
Created attachment 32578 [details]
Result of -save-temps

When compiling gambatte r550 (http://sourceforge.net/projects/gambatte/files/gambatte/r550/gambatte_src-r550.tar.gz) on NetBSD-6.99.40/amd64 with the g++ coming with that version of NetBSD, a file in libgambatte/ triggers an internal compiler error:

#  g++ -v -save-temps -o src/cpu.o -c -Wall -Wextra -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -DHAVE_STDINT_H -Isrc -Iinclude -I/disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common src/cpu.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64--netbsd
Configured with: /usr/src6/tools/gcc/../../external/gpl3/gcc/dist/configure --target=x86_64--netbsd --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb1 20120916' --with-system-zlib --enable-__cxa_atexit --with-tune=nocona --with-mpc-lib=/var/obj/mknative/amd64-x86_64/usr/src6/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/amd64-x86_64/usr/src6/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/amd64-x86_64/usr/src6/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/src6/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/src6/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/src6/external/lgpl3/gmp/lib/libgmp/arch/x86_64 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=x86_64--netbsd --with-sysroot=/var/obj/mknative/amd64-x86_64/usr/src6/destdir.amd64
Thread model: posix
gcc version 4.8.3 (NetBSD nb2 20140304)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'src/cpu.o' '-c' '-Wall' '-Wextra' '-O2' '-fomit-frame-pointer' '-fno-exceptions' '-fno-rtti' '-D' 'HAVE_STDINT_H' '-I' 'src' '-I' 'include' '-I' '/disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common' '-shared-libgcc' '-mtune=nocona' '-march=x86-64'
 /usr/libexec/cc1plus -E -quiet -v -I src -I include -I /disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common -D HAVE_STDINT_H src/cpu.cpp -mtune=nocona -march=x86-64 -Wall -Wextra -fomit-frame-pointer -fno-exceptions -fno-rtti -O2 -fpch-preprocess -o cpu.ii
#include "..." search starts here:
#include <...> search starts here:
 src
 include
 /disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common
 /usr/include/g++
 /usr/include/g++/backward
 /usr/include/gcc-4.8
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'src/cpu.o' '-c' '-Wall' '-Wextra' '-O2' '-fomit-frame-pointer' '-fno-exceptions' '-fno-rtti' '-D' 'HAVE_STDINT_H' '-I' 'src' '-I' 'include' '-I' '/disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common' '-shared-libgcc' '-mtune=nocona' '-march=x86-64'
 /usr/libexec/cc1plus -fpreprocessed cpu.ii -quiet -dumpbase cpu.cpp -mtune=nocona -march=x86-64 -auxbase-strip src/cpu.o -O2 -Wall -Wextra -version -fomit-frame-pointer -fno-exceptions -fno-rtti -o cpu.s
GNU C++ (NetBSD nb2 20140304) version 4.8.3 (x86_64--netbsd)
        compiled by GNU C version 4.2.1 Compatible Clang 3.5 (trunk 202566), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (NetBSD nb2 20140304) version 4.8.3 (x86_64--netbsd)
        compiled by GNU C version 4.2.1 Compatible Clang 3.5 (trunk 202566), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4054f87540345d4e138a62067c6e8c30
In file included from /usr/include/g++/string:53:0,
                 from include/loadres.h:4,
                 from src/mem/cartridge.h:22,
                 from src/memory.h:22,
                 from src/cpu.h:22,
                 from src/cpu.cpp:19:
/usr/include/g++/bits/basic_string.tcc: In copy constructor ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&)’:
/usr/include/g++/bits/basic_string.tcc:173:26: internal compiler error: Segmentation fault
     __str.get_allocator())
                          ^
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://www.NetBSD.org/Misc/send-pr.html> for instructions.


Starting cc1plus in gdb gives the following backtrace:

(gdb) r -quiet -v -I src -I include -I /disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common -D HAVE_STDINT_H src/cpu.cpp -quiet -dumpbase cpu.cpp -mtune=nocona -march=x86-64 -auxbase-strip sr
c/cpu.o -O2 -Wall -Wextra -version -fomit-frame-pointer -fno-exceptions -fno-rtti -o /var/tmp//ccfIzQKQ.s
Starting program: /usr/libexec/cc1plus -quiet -v -I src -I include -I /disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common -D HAVE_STDINT_H src/cpu.cpp -quiet -dumpbase cpu.cpp -mtune=nocona 
-march=x86-64 -auxbase-strip src/cpu.o -O2 -Wall -Wextra -version -fomit-frame-pointer -fno-exceptions -fno-rtti -o /var/tmp//ccfIzQKQ.s
GNU C++ (NetBSD nb2 20140304) version 4.8.3 (x86_64--netbsd)
        compiled by GNU C version 4.2.1 Compatible Clang 3.5 (trunk 202566), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
 src  
 include
 /disk/3/archive/obj/wip/gambatte-dev/work.x86_64/gambatte_src-r550/common
 /usr/include/g++
 /usr/include/g++/backward
 /usr/include/gcc-4.8
 /usr/include
End of search list.
GNU C++ (NetBSD nb2 20140304) version 4.8.3 (x86_64--netbsd)
        compiled by GNU C version 4.2.1 Compatible Clang 3.5 (trunk 202566), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4054f87540345d4e138a62067c6e8c30

Program received signal SIGSEGV, Segmentation fault.
0x00000000004f7670 in poplevel_class () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/name-lookup.c:2860
2860              IDENTIFIER_BINDING (cb->identifier) = cb->base->previous;
(gdb) bt
#0  0x00000000004f7670 in poplevel_class () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/name-lookup.c:2860
#1  0x0000000000459b9c in popclass () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/class.c:6935
#2  pop_nested_class () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/class.c:7081
#3  0x000000000042a934 in finish_function (flags=<optimized out>) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/decl.c:13991
#4  0x000000000048d01a in cp_parser_function_definition_after_declarator (parser=0x7f7ff6035bb0, inline_p=false) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:21837
#5  0x0000000000478f98 in cp_parser_function_definition_from_specifiers_and_declarator (parser=<optimized out>, decl_specifiers=<optimized out>, attributes=<optimized out>, declarator=<optimized out>)
    at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:21752
#6  cp_parser_init_declarator (parser=0x7f7ff6035bb0, decl_specifiers=<optimized out>, checks=<optimized out>, function_definition_allowed_p=<optimized out>, member_p=<optimized out>, 
    declares_class_or_enum=<optimized out>, function_definition_p=<optimized out>, maybe_range_for_decl=<optimized out>) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:15905
#7  0x000000000049efee in cp_parser_single_declaration (parser=0x7f7ff6035bb0, checks=0x0, member_p=false, explicit_specialization_p=false, friend_p=<optimized out>)
    at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:22127
#8  0x000000000049e573 in cp_parser_template_declaration_after_export (parser=0x7f7ff6035bb0, member_p=false) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:21941
#9  0x0000000000472bf7 in cp_parser_template_declaration (parser=0x7f7ff6035bb0, member_p=false) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:12226
#10 cp_parser_declaration (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:10404
#11 0x0000000000470c58 in cp_parser_declaration_seq_opt (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:10334
#12 0x00000000004738d8 in cp_parser_namespace_body (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:15136
#13 cp_parser_namespace_definition (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:15117
#14 0x0000000000472b49 in cp_parser_declaration (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:10432
#15 0x0000000000470c58 in cp_parser_declaration_seq_opt (parser=0x7f7ff6035bb0) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:10334
#16 0x000000000046fcff in cp_parser_translation_unit (parser=<optimized out>) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:3813
#17 c_parse_file () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/cp/parser.c:28334
#18 0x00000000005387a4 in c_common_parse_file () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/c-family/c-opts.c:1046
#19 0x000000000067c3aa in compile_file () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/toplev.c:543
#20 0x000000000067c207 in do_compile () at /archive/foreign/src/external/gpl3/gcc/dist/gcc/toplev.c:1864
#21 toplev_main (argc=28, argv=0x7f7fffffd310) at /archive/foreign/src/external/gpl3/gcc/dist/gcc/toplev.c:1940
#22 0x0000000000403059 in ___start ()
#23 0x00007f7ff7c042c0 in ?? () at /archive/foreign/src/libexec/ld.elf_so/rtld.c:1426 from /libexec/ld.elf_so
#24 0x00007f7ff7ffa000 in ?? ()
#25 0x000000000000001c in ?? ()
(lots more ??)

The cpu.ii file is attached.
Comment 1 Thomas Klausner 2014-04-10 10:13:24 UTC
This was first filed in the NetBSD bug tracker at
http://gnats.netbsd.org/48731
where it was suggested to file this upstream.
Comment 2 Markus Trippelsdorf 2014-04-10 10:35:30 UTC
I cannot reproduce this ICE.
Comment 3 Jakub Jelinek 2014-04-10 10:40:10 UTC
Can't reproduce this on Linux/x86_64.
Comment 4 Martin Husemann 2014-04-10 14:54:45 UTC
Neither can I on NetBSD/amd64 - will check with Thomas for differences on his system
Comment 5 Martin Husemann 2014-04-11 14:31:32 UTC
Thomas and I compared environments and found the difference: it is gcc compiled by clang that misbehaves. I could reproduce and verify it - but past bootstrapping it is something that will never happen to native FSF gcc in the wild, I suppose.
Comment 6 Markus Trippelsdorf 2014-04-11 14:35:31 UTC
Closing.