public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104107] New: parsing crashes on class template instantiation
@ 2022-01-19  0:01 gzoumix at hotmail dot com
  2022-01-19  0:14 ` [Bug c++/104107] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: gzoumix at hotmail dot com @ 2022-01-19  0:01 UTC (permalink / raw)
  To: gcc-bugs

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

            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<int targ_id, typename t_parameter, template<typename T, const T&>
typename tt_w_data>
struct tt_main {
  static t_parameter m_parameter;
  template<template<typename T, const T&> typename t_data> using t_make =
t_data<t_parameter, m_parameter>;
  using t_data = t_make<tt_w_data>;
};

template<int targ_id, typename t_parameter, template<typename T, const T&>
typename tt_w_data>
t_parameter tt_main<targ_id, t_parameter, tt_w_data>::m_parameter;

template<typename T, const T&> struct P {};
struct t_parameter {};

using toto = tt_main<0, t_parameter, P>;

int main() {
  toto t;
  return 0;
}

command line: g++ -v -save-temps -Wall -Wextra -std=c++17 prog.cc

error message:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/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 11.2.0-7ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--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 --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --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-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr
--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 11.2.0 (Ubuntu 11.2.0-7ubuntu2) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++17'
'-shared-libgcc' '-mtune=generic' '-march=x86-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=generic -march=x86-64 -std=c++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-fixed"
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='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++17'
'-shared-libgcc' '-mtune=generic' '-march=x86-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=generic -march=x86-64
-Wall -Wextra -std=c++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=100 --param ggc-min-heapsize=131072
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=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b2aa013a9bb78f98e29ce58cd37c6337
prog.cc: In instantiation of ‘struct tt_main<0, t_parameter, P>’:
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 = t_make<tt_w_data>;
      |         ^~~~~~
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 <file:///usr/share/doc/gcc-11/README.Bugs> 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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-07-07  9:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19  0:01 [Bug c++/104107] New: parsing crashes on class template instantiation gzoumix at hotmail dot com
2022-01-19  0:14 ` [Bug c++/104107] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-19  0:30 ` pinskia at gcc dot gnu.org
2022-01-19  0:31 ` pinskia at gcc dot gnu.org
2022-01-19 10:57 ` rguenth at gcc dot gnu.org
2022-01-31 15:11 ` [Bug c++/104107] [9/10/11/12 Regression] parsing crashes on class template instantiation since r9-6853-g17838af989014f5e marxin at gcc dot gnu.org
2022-02-10 22:55 ` jason at gcc dot gnu.org
2022-02-15  5:06 ` cvs-commit at gcc dot gnu.org
2022-02-16  0:12 ` [Bug c++/104107] [9/10/11 " jason at gcc dot gnu.org
2022-03-28 19:13 ` cvs-commit at gcc dot gnu.org
2022-03-28 19:13 ` [Bug c++/104107] [9/10 " jason at gcc dot gnu.org
2022-05-27  9:47 ` [Bug c++/104107] [10 " rguenth at gcc dot gnu.org
2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-03-15 12:45 ` cvs-commit at gcc dot gnu.org
2023-07-07  9:49 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).