public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module
@ 2023-11-17 14:24 nickbegg at gmail dot com
2023-11-18 0:40 ` [Bug c++/112588] " nathanieloshead at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: nickbegg at gmail dot com @ 2023-11-17 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Bug ID: 112588
Summary: ICE in make_decl_rtl when returning str literal when
string header imported in module
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nickbegg at gmail dot com
Target Milestone: ---
Created attachment 56622
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56622&action=edit
-freport-bug output
/home/nick/gcc-trunk-debug-inst/include/c++/14.0.0/bits/allocator.h:191:39:
internal compiler error: in make_decl_rtl, at varasm.cc:1442
191 | if (__builtin_mul_overflow(__n, sizeof(_Tp), &__n))
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Using when importing a module into a non-module TU, #including string in both
causes an ICE when returning a string literal in a function with std::string
return type -
////////////////////////
// modA.mpp (compiled as module):
module;
#include <string>
export module modA;
///////////////////////
// main.cpp (compiled as regular TU):
#include <string>
import modA;
std::string test_func() {
return "foo";
}
int main() {
return 0;
}
///////////////////////
The ICE happens when compiling main.cpp.
Removing the import from main.cpp, or returning std::string() from test_func()
stops the ICE.
GCC trunk (14) version, git rev ba3f5b8465ef7b278ea33ff94cd85b9638058635
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
@ 2023-11-18 0:40 ` nathanieloshead at gmail dot com
2023-12-01 9:10 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: nathanieloshead at gmail dot com @ 2023-11-18 0:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Nathaniel Shead <nathanieloshead at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathanieloshead at gmail dot com
--- Comment #1 from Nathaniel Shead <nathanieloshead at gmail dot com> ---
Minimised (the actual offender here is the with std::allocator<char>):
// test.h
void f(int*);
template <typename T>
struct S {
void g(int n) { f(&n); }
};
template struct S<void>;
// a.cpp
module;
#include "test.h"
export module test;
// b.cpp
#include "test.h"
import test;
So far it seems the issue is that the PARM_DECL in the expression tree of the
body of the instantiation for `S<void>::g` is a different node from the actual
PARM_DECL in g's DECL_ARGUMENTS; the latter gets RTL but the former does not.
The issue is in the deduplication logic for instantiations somewhere.
The following patch fixes this issue but causes other issues in the testsuite,
and I don't think this is the correct approach anyway:
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 4f5b6e2747a..f2d191fc408 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -8302,9 +8302,7 @@ trees_in::decl_value ()
if (TREE_CODE (inner) == FUNCTION_DECL)
{
tree e_inner = STRIP_TEMPLATE (existing);
- for (auto parm = DECL_ARGUMENTS (inner);
- parm; parm = DECL_CHAIN (parm))
- DECL_CONTEXT (parm) = e_inner;
+ DECL_ARGUMENTS (inner) = DECL_ARGUMENTS (e_inner);
}
/* And our result is the existing node. */
(I was originally working on this after attempting to reduce PR99999.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
2023-11-18 0:40 ` [Bug c++/112588] " nathanieloshead at gmail dot com
@ 2023-12-01 9:10 ` pinskia at gcc dot gnu.org
2024-01-08 17:06 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-01 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ma.anshukov at gmail dot com
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112805 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
2023-11-18 0:40 ` [Bug c++/112588] " nathanieloshead at gmail dot com
2023-12-01 9:10 ` pinskia at gcc dot gnu.org
@ 2024-01-08 17:06 ` ppalka at gcc dot gnu.org
2024-01-17 23:48 ` [Bug c++/112588] [modules] " cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-08 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99244
CC| |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The proposed patch seems to fix PR99244 as well
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] [modules] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
` (2 preceding siblings ...)
2024-01-08 17:06 ` ppalka at gcc dot gnu.org
@ 2024-01-17 23:48 ` cvs-commit at gcc dot gnu.org
2024-01-19 1:00 ` hp at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-17 23:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:3471a61ed0ddef70de8f1bbba85cd1e945fc86fd
commit r14-8196-g3471a61ed0ddef70de8f1bbba85cd1e945fc86fd
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Sat Dec 16 21:34:45 2023 +1100
c++: Prevent overwriting arguments when merging duplicates [PR112588]
When merging duplicate instantiations of function templates, currently
read_function_def overwrites the arguments with that of the existing
duplicate. This is problematic, however, since this means that the
PARM_DECLs in the body of the function definition no longer match with
the PARM_DECLs in the argument list, which causes issues when it comes
to generating RTL.
There doesn't seem to be any reason to do this replacement, so this
patch removes that logic.
PR c++/112588
gcc/cp/ChangeLog:
* module.cc (trees_in::read_function_def): Don't overwrite
arguments.
gcc/testsuite/ChangeLog:
* g++.dg/modules/merge-16.h: New test.
* g++.dg/modules/merge-16_a.C: New test.
* g++.dg/modules/merge-16_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] [modules] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
` (3 preceding siblings ...)
2024-01-17 23:48 ` [Bug c++/112588] [modules] " cvs-commit at gcc dot gnu.org
@ 2024-01-19 1:00 ` hp at gcc dot gnu.org
2024-01-27 10:31 ` nshead at gcc dot gnu.org
2024-03-06 22:08 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: hp at gcc dot gnu.org @ 2024-01-19 1:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hp at gcc dot gnu.org
--- Comment #5 from Hans-Peter Nilsson <hp at gcc dot gnu.org> ---
Looks like that commit also fixed the remaining g++.dg/modules/hello-1
execution failure for PR113038!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] [modules] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
` (4 preceding siblings ...)
2024-01-19 1:00 ` hp at gcc dot gnu.org
@ 2024-01-27 10:31 ` nshead at gcc dot gnu.org
2024-03-06 22:08 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-01-27 10:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Keywords| |ice-on-valid-code
Status|UNCONFIRMED |RESOLVED
Assignee|unassigned at gcc dot gnu.org |nshead at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/112588] [modules] ICE in make_decl_rtl when returning str literal when string header imported in module
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
` (5 preceding siblings ...)
2024-01-27 10:31 ` nshead at gcc dot gnu.org
@ 2024-03-06 22:08 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-06 22:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |f.b.brokken at rug dot nl
--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 104202 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-03-06 22:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 14:24 [Bug c++/112588] New: ICE in make_decl_rtl when returning str literal when string header imported in module nickbegg at gmail dot com
2023-11-18 0:40 ` [Bug c++/112588] " nathanieloshead at gmail dot com
2023-12-01 9:10 ` pinskia at gcc dot gnu.org
2024-01-08 17:06 ` ppalka at gcc dot gnu.org
2024-01-17 23:48 ` [Bug c++/112588] [modules] " cvs-commit at gcc dot gnu.org
2024-01-19 1:00 ` hp at gcc dot gnu.org
2024-01-27 10:31 ` nshead at gcc dot gnu.org
2024-03-06 22:08 ` 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).