public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module
@ 2021-05-15 18:59 amorvincitomnia.iw at gmail dot com
2021-05-15 20:11 ` [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module amorvincitomnia.iw at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: amorvincitomnia.iw at gmail dot com @ 2021-05-15 18:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
Bug ID: 100616
Summary: [modules] ICE when a class template taking a non-type
template argument is used both inside and outside the
defining module
Product: gcc
Version: 11.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amorvincitomnia.iw at gmail dot com
Target Milestone: ---
See it live: https://wandbox.org/permlink/QUKvRN5GI1feSldA
Minimal code to reproduce ICE:
// test.cc
export module test;
export
{
struct A{};
template <auto x>
struct C {
};
C<A{}> c1;
}
// prog.cc
import test;
C<1> c2;
Compile this with:
$ g++ "-std=c++20" "-fmodules-ts" "test.cc" "prog.cc"
Generates:
In module test, imported at prog.cc:2:
test.cc: In instantiation of 'struct C@test<1>':
prog.cc:3:6: required from here
test.cc:8:12: internal compiler error: Segmentation fault
8 | struct C {
| ^
0xcac40f crash_signal
../../source/gcc/toplev.c:327
0x7e6673 comptypes(tree_node*, tree_node*, int)
../../source/gcc/cp/typeck.c:1544
0x7e6673 comptypes(tree_node*, tree_node*, int)
../../source/gcc/cp/typeck.c:1527
0x6a894f complete_vars(tree_node*)
../../source/gcc/cp/decl.c:17761
0x65f97b finish_struct_1(tree_node*)
../../source/gcc/cp/class.c:7505
0x7b1014 instantiate_class_template_1
../../source/gcc/cp/pt.c:12248
0x7b1e42 instantiate_class_template(tree_node*)
../../source/gcc/cp/pt.c:12288
0x7e380b complete_type(tree_node*)
../../source/gcc/cp/typeck.c:143
0x7e380b complete_type(tree_node*)
../../source/gcc/cp/typeck.c:111
0x6a1aeb start_decl_1(tree_node*, bool)
../../source/gcc/cp/decl.c:5677
0x6b283f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../source/gcc/cp/decl.c:5643
0x771343 cp_parser_init_declarator
../../source/gcc/cp/parser.c:21759
0x74fac4 cp_parser_simple_declaration
../../source/gcc/cp/parser.c:14464
0x779cb5 cp_parser_declaration
../../source/gcc/cp/parser.c:14161
0x77a98e cp_parser_toplevel_declaration
../../source/gcc/cp/parser.c:14190
0x77a98e cp_parser_translation_unit
../../source/gcc/cp/parser.c:4942
0x77a98e c_parse_file()
../../source/gcc/cp/parser.c:45372
0x84b46d c_common_parse_file()
../../source/gcc/c-family/c-opts.c:1218
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Reproduces in both g++ 11.1.0 and 12.0.0 20210510.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
@ 2021-05-15 20:11 ` amorvincitomnia.iw at gmail dot com
2021-05-16 9:22 ` amorvincitomnia.iw at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: amorvincitomnia.iw at gmail dot com @ 2021-05-15 20:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
--- Comment #1 from wang ivor <amorvincitomnia.iw at gmail dot com> ---
Seems like the same bug happens whenever you use a class template with a
non-type template argument in two modules with dependency. This seems to be a
pretty serious bug that renders non-type template argument basically unusable
inside modules.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
2021-05-15 20:11 ` [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module amorvincitomnia.iw at gmail dot com
@ 2021-05-16 9:22 ` amorvincitomnia.iw at gmail dot com
2022-09-29 11:42 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: amorvincitomnia.iw at gmail dot com @ 2021-05-16 9:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
--- Comment #2 from wang ivor <amorvincitomnia.iw at gmail dot com> ---
One workaround I found is to always use templates to refer to C inside modules
and only ever instantiate them in the outermost translation units.
Or, if you only instantiate C with template arguments of primitive types (e.g.
int, char, pointer types of primitive types, etc.) this bug doesn't happen.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
2021-05-15 20:11 ` [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module amorvincitomnia.iw at gmail dot com
2021-05-16 9:22 ` amorvincitomnia.iw at gmail dot com
@ 2022-09-29 11:42 ` cvs-commit at gcc dot gnu.org
2022-09-29 21:05 ` ppalka at gcc dot gnu.org
2022-10-18 15:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-29 11:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:
https://gcc.gnu.org/g:a1f7f9541c2b20eb44750b9c15cd831c62d67f21
commit r13-2953-ga1f7f9541c2b20eb44750b9c15cd831c62d67f21
Author: Nathan Sidwell <nathan@acm.org>
Date: Wed Sep 28 09:21:14 2022 -0700
c++: import/export NTTP objects
This adds smarts to the module machinery to handle NTTP object
VAR_DECLs. Like typeinfo objects, these must be ignored in the symbol
table, streamed specially and recreated on stream in.
gcc/cp/
PR c++/100616
* module.cc (enum tree_tag): Add tt_nttp_var.
(trees_out::decl_node): Handle NTTP objects.
(trees_in::tree_node): Handle tt_nttp_var.
(depset::hash::add_binding_entry): Skip NTTP objects.
gcc/testsuite/
PR c++/100616
* g++.dg/modules/100616_a.H: New.
* g++.dg/modules/100616_b.C: New.
* g++.dg/modules/100616_c.C: New.
* g++.dg/modules/100616_d.C: New.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
` (2 preceding siblings ...)
2022-09-29 11:42 ` cvs-commit at gcc dot gnu.org
@ 2022-09-29 21:05 ` ppalka at gcc dot gnu.org
2022-10-18 15:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-09-29 21:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |13.0
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
` (3 preceding siblings ...)
2022-09-29 21:05 ` ppalka at gcc dot gnu.org
@ 2022-10-18 15:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-18 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100616
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |johelegp at gmail dot com
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 105044 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-18 15:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 18:59 [Bug c++/100616] New: [modules] ICE when a class template taking a non-type template argument is used both inside and outside the defining module amorvincitomnia.iw at gmail dot com
2021-05-15 20:11 ` [Bug c++/100616] [modules] ICE when a variable of class taking a non-type template argument is defined both inside and outside the module amorvincitomnia.iw at gmail dot com
2021-05-16 9:22 ` amorvincitomnia.iw at gmail dot com
2022-09-29 11:42 ` cvs-commit at gcc dot gnu.org
2022-09-29 21:05 ` ppalka at gcc dot gnu.org
2022-10-18 15:10 ` ppalka 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).