public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775
@ 2022-06-17 3:12 overlord624 at gmail dot com
2022-06-17 3:14 ` [Bug c++/106009] " overlord624 at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: overlord624 at gmail dot com @ 2022-06-17 3:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
Bug ID: 106009
Summary: [modules] internal compiler error: in mark_by_value,
at cp/module.cc:4775
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: overlord624 at gmail dot com
Target Milestone: ---
Created attachment 53158
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53158&action=edit
output with -freport-bug
Trying to compile the spdlog library to a header unit causes an internal
compiler error. Adding -save-temps to the parameters causes the same error, but
the compiler claims the error is non-reproducible. No errors occur when the
same header is included in the global module fragment of a regular module.
$ g++-exp -freport-bug -fmodules-ts -std=c++20 -Wall -Wextra -pedantic
-DSPDLOG_COMPILED_LIB -x c++-system-header spdlog/spdlog.h
/usr/include/spdlog/spdlog.h: internal compiler error: in mark_by_value, at
cp/module.cc:4775
0x7112a2 trees_out::mark_by_value(tree_node*)
/media/extra/sources/gcc/gcc/cp/module.cc:4775
0xabe961 trees_out::mark_declaration(tree_node*, bool)
/media/extra/sources/gcc/gcc/cp/module.cc:12245
0xabebd9 trees_out::mark_class_def(tree_node*)
/media/extra/sources/gcc/gcc/cp/module.cc:11744
0xac859d depset::hash::find_dependencies(module_state*)
/media/extra/sources/gcc/gcc/cp/module.cc:13126
0xac8cc0 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
/media/extra/sources/gcc/gcc/cp/module.cc:17640
0xac9f84 finish_module_processing(cpp_reader*)
/media/extra/sources/gcc/gcc/cp/module.cc:19962
0xa58c85 c_parse_final_cleanups()
/media/extra/sources/gcc/gcc/cp/decl2.cc:5156
0xc7ab60 c_common_parse_file()
/media/extra/sources/gcc/gcc/c-family/c-opts.cc:1253
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/cc4TWK1u.out file, please attach this to
your bugreport.
$ g++-exp -v
Using built-in specs.
COLLECT_GCC=g++-exp
COLLECT_LTO_WRAPPER=/media/extra/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /media/extra/sources/gcc/configure --host=x86_64-pc-linux-gnu
--prefix=/media/extra --disable-multilib --enable-threads --enable-tls
--enable-languages=c,c++ --disable-nls
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220616 (experimental) (GCC)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
@ 2022-06-17 3:14 ` overlord624 at gmail dot com
2022-10-18 0:33 ` [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit ppalka at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: overlord624 at gmail dot com @ 2022-06-17 3:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
--- Comment #1 from John Smith <overlord624 at gmail dot com> ---
Created attachment 53159
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53159&action=edit
preprocessed with -save-temps
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
2022-06-17 3:14 ` [Bug c++/106009] " overlord624 at gmail dot com
@ 2022-10-18 0:33 ` ppalka at gcc dot gnu.org
2024-02-13 19:01 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-18 0:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[modules] internal compiler |[modules] internal compiler
|error: in mark_by_value, at |error: in
|cp/module.cc:4775 |import_entity_index with
| |templated local enum in
| |header unit
CC| |ppalka at gcc dot gnu.org
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The mark_by_value ICE is fixed on trunk by r13-3166-gf7f4628054358a I suspect.
But we now crash from import_entity_index instead. Reduced reproducer:
$ cat 106009.H
template<class T>
void format_decimal(T) {
enum blah {};
}
inline void write() {
format_decimal(0);
}
$ g++ -fmodule-header 106009.H
106009.H: internal compiler error: in import_entity_index, at cp/module.cc:4071
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
2022-06-17 3:14 ` [Bug c++/106009] " overlord624 at gmail dot com
2022-10-18 0:33 ` [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit ppalka at gcc dot gnu.org
@ 2024-02-13 19:01 ` ppalka at gcc dot gnu.org
2024-02-29 18:04 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-13 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-02-13
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Keywords| |ice-checking,
| |ice-on-valid-code
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
FWIW also crash from import_entity_index if we use an undefined local struct:
template<class T>
void format_decimal(T) {
struct blah;
}
but not if we define it:
template<class T>
void format_decimal(T) {
struct blah {};
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
` (2 preceding siblings ...)
2024-02-13 19:01 ` ppalka at gcc dot gnu.org
@ 2024-02-29 18:04 ` ppalka at gcc dot gnu.org
2024-03-01 22:24 ` cvs-commit at gcc dot gnu.org
2024-03-01 22:26 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-02-29 18:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
` (3 preceding siblings ...)
2024-02-29 18:04 ` ppalka at gcc dot gnu.org
@ 2024-03-01 22:24 ` cvs-commit at gcc dot gnu.org
2024-03-01 22:26 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-01 22:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:574fd1f17f100c7c355ad26bc525ab5a3386bb2d
commit r14-9268-g574fd1f17f100c7c355ad26bc525ab5a3386bb2d
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Mar 1 17:24:15 2024 -0500
c++/modules: depending local enums [PR104919, PR106009]
For local enums defined in a non-template function or a function template
instantiation it seems we neglect to make the function depend on the enum
definition (which modules considers logically separate), which ultimately
causes the enum definition to not be properly streamed before uses
within the function definition are streamed.
The code responsible for noting such dependencies is
gcc/cp/module.cc
@@ -8784,17 +8784,6 @@ trees_out::decl_node (tree decl, walk_kind ref)
depset *dep = NULL;
if (streaming_p ())
dep = dep_hash->find_dependency (decl);
! else if (TREE_CODE (ctx) != FUNCTION_DECL
! || TREE_CODE (decl) == TEMPLATE_DECL
! || (dep_hash->sneakoscope && DECL_IMPLICIT_TYPEDEF_P (decl))
! || (DECL_LANG_SPECIFIC (decl)
! && DECL_MODULE_IMPORT_P (decl)))
! {
! auto kind = (TREE_CODE (decl) == NAMESPACE_DECL
! && !DECL_NAMESPACE_ALIAS (decl)
! ? depset::EK_NAMESPACE : depset::EK_DECL);
! dep = dep_hash->add_dependency (decl, kind);
! }
if (!dep)
{
and the condition there notably excludes local TYPE_DECLs from a
non-template-pattern function (when streaming a template pattern
we'll see be dealing with the corresponding TEMPLATE_DECL of the
local TYPE_DECL here, so we'll add the dependency).
Local classes on the other hand seem to work properly, but perhaps by
accident: with a local class we end up making the function depend on the
injected-class-name of the local class rather than the local class as a
whole because the injected-class-name satisfies the criteria (since its
context is the local class, not the function).
The 'sneakoscope' flag is set when walking a function declaration and
its purpose seems to be to catch a local type that escapes the function
via a deduced return type (so called voldemort types) and note a
dependency on them. But there seems to be no reason to restrict this
behavior to voldemort types, and indeed consistently noting the dependency
for all local types fixes these PRs (almost). So this patch gets rid of
this flag and enables the dependency tracking unconditionally.
This was nearly enough to make things work, except we now ran into
issues with the local TYPE_/CONST_DECL copies from the pre-gimplified
version of a constexpr function body during streaming. Rather than
making modules cope with this, it occurred to me that we don't need to
make copies of local types when saving the pre-gimplified body (and when
making further copies thereof); only VAR_DECLs etc need to be copied
(so that we don't conflate local variables from different recursive
calls to the same function during constexpr evaluation). So this patch
adjusts copy_fn accordingly.
PR c++/104919
PR c++/106009
gcc/cp/ChangeLog:
* module.cc (depset::hash::sneakoscope): Remove.
(trees_out::decl_node): Always add a dependency on a local type.
(depset::hash::find_dependencies): Remove sneakoscope stuff.
gcc/ChangeLog:
* tree-inline.cc (remap_decl): Handle copy_decl returning the
original decl.
(remap_decls): Handle remap_decl returning the original decl.
(copy_fn): Adjust copy_decl callback to skip TYPE_DECL and
CONST_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/modules/tdef-7.h: Remove outdated comment.
* g++.dg/modules/tdef-7_b.C: Don't expect two TYPE_DECLs.
* g++.dg/modules/enum-13_a.C: New test.
* g++.dg/modules/enum-13_b.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
` (4 preceding siblings ...)
2024-03-01 22:24 ` cvs-commit at gcc dot gnu.org
@ 2024-03-01 22:26 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-01 22:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106009
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-01 22:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 3:12 [Bug c++/106009] New: [modules] internal compiler error: in mark_by_value, at cp/module.cc:4775 overlord624 at gmail dot com
2022-06-17 3:14 ` [Bug c++/106009] " overlord624 at gmail dot com
2022-10-18 0:33 ` [Bug c++/106009] [modules] internal compiler error: in import_entity_index with templated local enum in header unit ppalka at gcc dot gnu.org
2024-02-13 19:01 ` ppalka at gcc dot gnu.org
2024-02-29 18:04 ` ppalka at gcc dot gnu.org
2024-03-01 22:24 ` cvs-commit at gcc dot gnu.org
2024-03-01 22:26 ` 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).