https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125769
Bug ID: 125769
Summary: [C++20] ICE in lvalue_kind with class-type NTTP as
alias-template argument
Product: gcc
Version: 13.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lslim at nvidia dot com
Target Milestone: ---
Created attachment 64724
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64724&action=edit
Standalone reproducer
GCC ICE on the following well-formed C++20 program.
The crash requires the combination of three things; dropping any compiles
cleanly:
1. a class-type non-type template parameter,
2. bound to an ALIAS template, and
3. instantiated with a DEPENDENT value.
Minimal, self-contained testcase (no #includes):
------------------------------------------------------------
struct Cfg { bool flag; };
template<Cfg C>
struct Wrap { static constexpr bool value = C.flag; };
template<Cfg C>
using Pick = Wrap<C>; // alias template with a class-type NTTP
template<int N>
struct Table { static constexpr Cfg v{true}; };
template<int N>
using Use = Pick<Table<N>::v>; // alias fed a DEPENDENT class-type value
static_assert(Use<0>::value);
------------------------------------------------------------
Compile command:
g++ -std=c++20 -c gcc_nttp_alias_ice.cpp
Output:
gcc_nttp_alias_ice.cpp: In substitution of 'template<Cfg C> using Pick =
Wrap<((const Cfg)C)> [with Cfg C = Table<N>::v]':
gcc_nttp_alias_ice.cpp:13:29: required from here
gcc_nttp_alias_ice.cpp:7:7: internal compiler error: in lvalue_kind, at
cp/tree.cc:223
7 | using Pick = Wrap<C>; // alias template whose NTTP is
the class type Cfg
| ^~~~
0x1153298 internal_error(char const*, ...)
???:0
0x1147927 fancy_abort(char const*, int, char const*)
???:0
0x1347178 lvalue_kind(tree_node const*)
???:0
0x1439c5f coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
???:0
0x1433644 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x14e29bf instantiate_template(tree_node*, tree_node*, int)
???:0
0x1442fc0 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x1434281 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
???:0
0x1433151 finish_template_type(tree_node*, tree_node*, int)
???:0
0x17c82f9 c_parse_file()
???:0
0x17ae77c c_common_parse_file()
???:0
Cross-version behaviour:
- gcc 13.3.0 : internal compiler error: in lvalue_kind, at
cp/tree.cc:223
- gcc 11.4.0 : internal compiler error: Segmentation fault (in
cp_type_quals)
gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
13.3.0-6ubuntu2~24.04.1' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-13
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-13-EldibY/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-EldibY/gcc-13-13.3.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1)