https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101303
Bug ID: 101303 Summary: ICE from modified lambda-generic-100362.C test case from bug 100362 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: enolan at alumni dot cmu.edu Target Milestone: --- When I was checking whether the fix for bug 100362 worked, I noticed that although it fixed the minimal test case I provided, the original code from which I'd minified it still crashed GCC. After some diffing I discovered that the following slight modification of the gcc test case, lambda-generic-100362.C, still caused an ICE. The cpp file I used is as follows: template <class> struct Qux { struct A { } a_; A f(); void AsyncOp() { [this](auto) { using Foo = decltype(a_); struct local : Foo {}; local ptr; }(0); } }; void corge() { Qux<int> qux; qux.AsyncOp(); } The changes from the original test case are that "struct local" inherits with a "using" declaration instead of inheriting from "decltype(a_)" directly, and that the lambda captures "this". Although the version details included below are from a build of gcc from the latest master, I also tested this with GCC 9.3.0, and it ICEd that version as well. > the exact version of GCC I used Spack to build GCC from commit hash 58b735. (I accidentally tagged it "11.1.0.58b735" even though it's 12.0.0.) gcc version 12.0.0 20210701 (experimental) (Spack GCC) > the system type Ubuntu 21.04 > the options given when GCC was configured/built Configured with: /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/configure --prefix=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb --with-pkgversion='Spack GCC' --with-bugurl=https://github.com/spack/spack/issues --disable-multilib --enable-languages=c,c++,fortran --disable-nls --with-system-zlib --with-zstd-include=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zstd-1.4.9-g5e5ekytpmwt4p2s2whwo5n23uezvaau/include --with-zstd-lib=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zstd-1.4.9-g5e5ekytpmwt4p2s2whwo5n23uezvaau/lib --with-mpfr-include=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpfr-4.1.0-wkdcn7axxshpddf24rlmrgbnl4b5x4uj/include --with-mpfr-lib=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpfr-4.1.0-wkdcn7axxshpddf24rlmrgbnl4b5x4uj/lib --with-gmp-include=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gmp-6.2.1-y5nxi6djabr65jjm4pquijfju46tioyl/include --with-gmp-lib=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gmp-6.2.1-y5nxi6djabr65jjm4pquijfju46tioyl/lib --with-mpc-include=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpc-1.1.0-v6jniwtyay66af7sk43c75njjrsoyjns/include --with-mpc-lib=/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpc-1.1.0-v6jniwtyay66af7sk43c75njjrsoyjns/lib --without-isl --with-stage1-ldflags='-Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/lib64 -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gmp-6.2.1-y5nxi6djabr65jjm4pquijfju46tioyl/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpfr-4.1.0-wkdcn7axxshpddf24rlmrgbnl4b5x4uj/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpc-1.1.0-v6jniwtyay66af7sk43c75njjrsoyjns/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zlib-1.2.11-xfc275gqwmrd3cwbjnqbnqx2u5gz444l/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zstd-1.4.9-g5e5ekytpmwt4p2s2whwo5n23uezvaau/lib' --with-boot-ldflags='-Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/lib64 -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/gmp-6.2.1-y5nxi6djabr65jjm4pquijfju46tioyl/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpfr-4.1.0-wkdcn7axxshpddf24rlmrgbnl4b5x4uj/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/mpc-1.1.0-v6jniwtyay66af7sk43c75njjrsoyjns/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zlib-1.2.11-xfc275gqwmrd3cwbjnqbnqx2u5gz444l/lib -Wl,-rpath,/home/enolan/spack/opt/spack/linux-ubuntu21.04-zen3/gcc-11.0.1/zstd-1.4.9-g5e5ekytpmwt4p2s2whwo5n23uezvaau/lib -static-libstdc++ -static-libgcc' > the complete command line that triggers the bug g++ -v -save-temps -std=c++17 -c ./ice.cpp > the compiler output (error messages, warnings, etc.) ./ice.cpp: In instantiation of 'struct Qux<int>::AsyncOp()::<lambda(auto:1)>::local': ./ice.cpp:10:13: required from 'Qux<int>::AsyncOp()::<lambda(auto:1)> [with auto:1 = int]' ./ice.cpp:11:6: required from 'void Qux< <template-parameter-1-1> >::AsyncOp() [with <template-parameter-1-1> = int]' ./ice.cpp:17:14: required from here ./ice.cpp:7:16: internal compiler error: in lookup_template_class_1, at cp/pt.c:10005 7 | [this](auto) { | ^ 0x6e97ee lookup_template_class_1 /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:10005 0xb00806 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:10244 0xb00806 tsubst_aggr_type /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:13609 0xaf455c tsubst(tree_node*, tree_node*, int, tree_node*) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:15472 0xadfe1c tsubst_decl /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:14481 0xad5a41 tsubst_copy /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:16575 0xad7480 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:20766 0xad7c82 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:19648 0xad7ec2 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:20546 0xae2718 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:19123 0xae0ad6 tsubst_decl /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:14831 0xad645c tsubst_copy /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:16710 0xad7480 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:20766 0xad7c82 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:19648 0xad7ec2 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:20546 0xaf4d1e tsubst(tree_node*, tree_node*, int, tree_node*) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:16126 0xb0d132 instantiate_class_template_1 /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:11900 0xb0eab2 instantiate_class_template(tree_node*) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:12282 0xb5b109 complete_type(tree_node*) /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/typeck.c:143 0xae0725 tsubst_decl /tmp/enolan/spack-stage/spack-stage-gcc-11.1.0.58b735-lfokficgbii3qo3wxptqa6cpavixfdwb/spack-src/gcc/cp/pt.c:14817 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. > the preprocessed file (*.i*) that triggers the bug, generated by adding > -save-temps to the complete compilation command, or, in the case of a bug report for the GNAT front end, a complete set of source files (see below). # 0 "./ice.cpp" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "./ice.cpp" template <class> struct Qux { struct A { } a_; A f(); void AsyncOp() { [this](auto) { using Foo = decltype(a_); struct local : Foo {}; local ptr; }(0); } }; void corge() { Qux<int> qux; qux.AsyncOp(); }