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

            Bug ID: 86060
           Summary: g++ ICE at on with "c++03" in tsubst_copy, at
                    cp/pt.c:15459
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: helloqirun at gmail dot com
  Target Milestone: ---

The trunk version g++ crashes with "-std=c++98" or "-std=c++03". The other std
flags seem working.

It seems to be a regression in 5.X. Gcc-4.9 works fine.

$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 9.0.0 20180604 (experimental) [trunk revision 261145] (GCC)



$ g++-trunk -std=c++11 -c abc.cpp

$ g++-trunk -std=c++98 -c abc.cpp
abc.cpp: In function ‘void foo(T (&)[8])’:
abc.cpp:2:16: warning: range-based ‘for’ loops only available with -std=c++11
or -std=gnu++11
   for (int i : a)
                ^
abc.cpp: In instantiation of ‘void foo(T (&)[8]) [with T = int]’:
abc.cpp:5:22:   required from here
abc.cpp:3:5: internal compiler error: in tsubst_copy, at cp/pt.c:15459
     i;
     ^
0x64601c tsubst_copy
        ../../gcc/gcc/cp/pt.c:15457
0x968c43 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:18862
0x974ab7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:17415
0x9727c6 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16616
0x97251d tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16811
0x971bbf tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16899
0x971517 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16587
0x971517 instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:24001
0x997023 instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:24117
0x8be968 c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:4703
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ cat abc.cpp
template <typename T> void foo(T (&a)[8]) {
  for (int i : a)
    i;
}
void fn1() { foo<int>; }

Reply via email to