[Bug c++/84001] New: ICE in dependent_type_p cp/pt.c:23567 when using member type of template parameter in template list

profclonk at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 23 18:20:00 GMT 2018


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

            Bug ID: 84001
           Summary: ICE in dependent_type_p cp/pt.c:23567 when using
                    member type of template parameter in template list
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: profclonk at gmail dot com
  Target Milestone: ---

Compiling this C++98 code:

struct X {
        typedef int Obj;
};

template <int I>
struct Y {};

template <typename A, typename A::Obj I>
void foo (A a, Y<I>) {  }

int main () {
        X x;
        Y<42> y;
        foo (x, y);
}

yields an internal compiler error:

test4.cc: In substitution of ‘template<class A, typename A::Obj I> void foo(A,
Y<I>) [with A = X; typename A::Obj I = <missing>]’:
test4.cc:14:11:   required from here
test4.cc:14:11: internal compiler error: in dependent_type_p, at cp/pt.c:23567
  foo (x, y);
           ^
0x5dc6bc dependent_type_p(tree_node*)
        ../../src/gcc/cp/pt.c:23567
0x5dd0b0 dependent_scope_p(tree_node*)
        ../../src/gcc/cp/pt.c:23598
0x5cffd7 make_typename_type(tree_node*, tree_node*, tag_types, int)
        ../../src/gcc/cp/decl.c:3784
0x5e4280 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../src/gcc/cp/pt.c:14066
0x5e1f1f unify
        ../../src/gcc/cp/pt.c:20659
0x5e1508 unify
        ../../src/gcc/cp/pt.c:20851
0x57f7db try_class_unification
        ../../src/gcc/cp/pt.c:19872
0x5e1e00 unify
        ../../src/gcc/cp/pt.c:20888
0x5f36e1 unify_one_argument
        ../../src/gcc/cp/pt.c:19128
0x5f8726 type_unification_real
        ../../src/gcc/cp/pt.c:19248
0x5fc75e fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../src/gcc/cp/pt.c:18633
0x5ae5f7 add_template_candidate_real
        ../../src/gcc/cp/call.c:3170
0x5a6034 add_template_candidate
        ../../src/gcc/cp/call.c:3252
0x5a6034 add_candidates
        ../../src/gcc/cp/call.c:5483
0x5b04b1 perform_overload_resolution
        ../../src/gcc/cp/call.c:4143
0x5b059e build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, bool, int)
        ../../src/gcc/cp/call.c:4232
0x6906f1 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ../../src/gcc/cp/semantics.c:2454
0x643c2c cp_parser_postfix_expression
        ../../src/gcc/cp/parser.c:6997
0x64455d cp_parser_unary_expression
        ../../src/gcc/cp/parser.c:8108
0x645303 cp_parser_cast_expression
        ../../src/gcc/cp/parser.c:8786

GCC Version information:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.2.0-1ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04) 

The problem exists at least since version 4.4.7 and also on 7.2.1 as tested on
godbolt.org. The system is x86-64 on Linux Mint (Ubuntu). The command line is:
g++ test4.cc
As no preprocessor directives were used, the preprocessed output is identical
to the shown source code. The code works on Clang.


More information about the Gcc-bugs mailing list