https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108975
Bug ID: 108975 Summary: Internal compiler error on constexpr variable used as nontype template Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: samuelpmish at gmail dot com Target Milestone: --- Hi, I'm running into an internal compiler error with g++ (12.1.0): internal compiler error: in lookup_template_class_1, at cp/pt.cc:10114 [build] 120 | using derivative_type = decltype(domain_integral::get_derivative_type<index, dim, trials...>(qf, state_type{})); [build] | ^~~ [build] 0x662042 lookup_template_class_1 [build] ../../src/gcc/cp/pt.cc:10114 [build] 0x81c004 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) [build] ../../src/gcc/cp/pt.cc:10353 [build] 0x81c004 tsubst_aggr_type [build] ../../src/gcc/cp/pt.cc:13747 [build] 0x80e549 tsubst_aggr_type [build] ../../src/gcc/cp/pt.cc:17421 [build] 0x80e549 tsubst_copy [build] ../../src/gcc/cp/pt.cc:16928 [build] 0x80fc58 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../src/gcc/cp/pt.cc:21050 [build] 0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../src/gcc/cp/pt.cc:19491 [build] 0x81cfb2 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../src/gcc/cp/pt.cc:18462 [build] 0x81cfb2 tsubst_decl [build] ../../src/gcc/cp/pt.cc:15004 [build] 0x80e92b tsubst_copy [build] ../../src/gcc/cp/pt.cc:17000 [build] 0x80f4e1 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../src/gcc/cp/pt.cc:21265 [build] 0x80fe8d tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../src/gcc/cp/pt.cc:20117 [build] 0x8200e8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../src/gcc/cp/pt.cc:19491 [build] 0x825bad tsubst_template_args(tree_node*, tree_node*, int, tree_node*) [build] ../../src/gcc/cp/pt.cc:13517 [build] 0x8108fe tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../src/gcc/cp/pt.cc:20055 [build] 0x80f865 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) [build] ../../src/gcc/cp/pt.cc:20676 [build] 0x818c01 tsubst(tree_node*, tree_node*, int, tree_node*) [build] ../../src/gcc/cp/pt.cc:16315 [build] 0x81c344 tsubst_decl [build] ../../src/gcc/cp/pt.cc:14952 [build] 0x8226bb tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../src/gcc/cp/pt.cc:18590 [build] 0x821632 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) [build] ../../src/gcc/cp/pt.cc:18462 g++ (11.3.0) also fails in a similar way: internal compiler error: in lookup_template_class_1, at cp/pt.c:10093 [build] 120 | using derivative_type = decltype(domain_integral::get_derivative_type<index, dim, trials...>(qf, state_type{})); [build] | ^~~ [build] 0x7fc84da29d8f __libc_start_call_main [build] ../sysdeps/nptl/libc_start_call_main.h:58 [build] 0x7fc84da29e3f __libc_start_main_impl [build] ../csu/libc-start.c:392 but g++ (10.4.0) and clang (14.0.0) compile the same code without any issues. ------------------------------------- The line of code it referred to before the backtrace is something like: constexpr int dim = dimension_of(geom); [&](auto index) { ... using derivative_type = decltype(domain_integral::get_derivative_type<index, dim, trials...>(qf, state_type{})); ... } If I make `dim` static in addition to constexpr, then the internal compiler error disappears. I've tried for a bit to come up with a smaller example that reproduces this issue, but wasn't able to find one. The full compilation line is (after removing some long include directory flags) /usr/bin/g++-12 -DAXOM_DEBUG -DGTEST_HAS_DEATH_TEST=0 -Wall -Wextra -pthread -freport-bug -Werror -Wshadow -Wdouble-promotion -Wconversion -Wundef -Wnull-dereference -Wold-style-cast -g -fPIE -fopenmp -Wno-class-memaccess -DCONDUIT_RELAY_IO_MPI_ENABLED -DCONDUIT_BLUEPRINT_MPI_ENABLED -std=c++17 -o file.o -c file.cpp Following the guidance in README.Bugs, I also compiled with -save-temps to produce a .ii file, but it is too large to attach here, so I'll include a dropbox link to it: https://www.dropbox.com/s/slrf8r500vargd5/file.ii?dl=0 I'm new to submitting bugs to gcc/g++, so if there's any more information I can provide please let me know. Sam