From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1DE1E3858409; Wed, 19 Jan 2022 00:01:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DE1E3858409 From: "gzoumix at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104107] New: parsing crashes on class template instantiation Date: Wed, 19 Jan 2022 00:01:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gzoumix at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2022 00:01:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104107 Bug ID: 104107 Summary: parsing crashes on class template instantiation Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gzoumix at hotmail dot com Target Milestone: --- The following code makes the g++ parser crash on all versions of gcc on wandbox.org, in C++17 and up. I also have the issue on my ubuntu 21.10 with= gcc 11.2.0. g++ --version: g++ (Ubuntu 11.2.0-7ubuntu2) 11.2.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. code: template typename tt_w_data> struct tt_main { static t_parameter m_parameter; template typename t_data> using t_make =3D t_data; using t_data =3D t_make; }; template typename tt_w_data> t_parameter tt_main::m_parameter; template struct P {}; struct t_parameter {}; using toto =3D tt_main<0, t_parameter, P>; int main() { toto t; return 0; } command line: g++ -v -save-temps -Wall -Wextra -std=3Dc++17 prog.cc error message: Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 11.2.0-7ub= untu2' --with-bugurl=3Dfile:///usr/share/doc/gcc-11/README.Bugs --enable-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix= =3D/usr --with-gcc-major-version-only --program-suffix=3D-11 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-= zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/= debian/tmp-nvptx/usr,amdgcn-amdhsa=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/deb= ian/tmp-gcn/usr --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu --with-build-config=3Dbootstrap-lto-lean --enable-link-serialization=3D2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)=20 COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-Wall' '-Wextra' '-std=3Dc++17' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' /usr/lib/gcc/x86_64-linux-gnu/11/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE prog.cc -mtune=3Dgeneric -march=3Dx86-64 -st= d=3Dc++17 -Wall -Wextra -fpch-preprocess -fasynchronous-unwind-tables -fstack-protector-strong -Wformat-security -fstack-clash-protection -fcf-protection -o a-prog.ii ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/11" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/include-fi= xed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/11 /usr/include/x86_64-linux-gnu/c++/11 /usr/include/c++/11/backward /usr/lib/gcc/x86_64-linux-gnu/11/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-Wall' '-Wextra' '-std=3Dc++17' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' /usr/lib/gcc/x86_64-linux-gnu/11/cc1plus -fpreprocessed a-prog.ii -quiet -dumpdir a- -dumpbase prog.cc -dumpbase-ext .cc -mtune=3Dgeneric -march=3Dx= 86-64 -Wall -Wextra -std=3Dc++17 -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat-security -fstack-clash-protection -fcf-protection -o a-prog.s GNU C++17 (Ubuntu 11.2.0-7ubuntu2) version 11.2.0 (x86_64-linux-gnu) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU C++17 (Ubuntu 11.2.0-7ubuntu2) version 11.2.0 (x86_64-linux-gnu) compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: b2aa013a9bb78f98e29ce58cd37c6337 prog.cc: In instantiation of =E2=80=98struct tt_main<0, t_parameter, P>=E2= =80=99: prog.cc:17:8: required from here prog.cc:5:9: internal compiler error: in tsubst, at cp/pt.c:15632 5 | using t_data =3D t_make; | ^~~~~~ 0x6fda34 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.c:15632 0x10a2bc8 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.c:15519 0x109aeef convert_template_argument ../../src/gcc/cp/pt.c:8522 0x109810f coerce_template_parms ../../src/gcc/cp/pt.c:9021 0x124bb50 coerce_template_template_parms ../../src/gcc/cp/pt.c:8001 0x109adbd convert_template_argument ../../src/gcc/cp/pt.c:8449 0x109810f coerce_template_parms ../../src/gcc/cp/pt.c:9021 0x10975de coerce_innermost_template_parms(tree_node*, tree_node*, tree_node= *, int, bool, bool) [clone .constprop.0] ../../src/gcc/cp/pt.c:9153 0x10a35f3 instantiate_alias_template ../../src/gcc/cp/pt.c:21237 0x10a35f3 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.c:15473 0x116aeef tsubst_decl ../../src/gcc/cp/pt.c:14831 0x1166064 instantiate_class_template_1 ../../src/gcc/cp/pt.c:12030 0xf45996 instantiate_class_template(tree_node*) ../../src/gcc/cp/pt.c:12272 0xf45996 complete_type(tree_node*) ../../src/gcc/cp/typeck.c:143 0xf45996 complete_type(tree_node*) ../../src/gcc/cp/typeck.c:111 0xfe4f5a start_decl_1(tree_node*, bool) ../../src/gcc/cp/decl.c:5644 0xfc32c8 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../src/gcc/cp/decl.c:5610 0xfa79a0 cp_parser_init_declarator ../../src/gcc/cp/parser.c:21763 0xf9fea9 cp_parser_simple_declaration ../../src/gcc/cp/parser.c:14467 0x1033d54 cp_parser_declaration_statement ../../src/gcc/cp/parser.c:13602 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. Thank you PS: when I remove the 'int targ_id' template argument, or when I inline the application of the 'tt_main::t_make' template in the definition of 'tt_main::t_data', the parsing error disappears.=