* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
@ 2024-04-21 22:17 ` porten at kde dot org
2024-04-22 0:20 ` porten at kde dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-21 22:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #1 from porten at kde dot org ---
Looking through the other c++-modules reports, I saw that someone reduced a
similar test case to an ICE in comment #3:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114600#c3 Therefore this bug
could be a duplicate of #114600.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
@ 2024-04-22 0:20 ` porten at kde dot org
2024-04-22 1:52 ` nshead at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22 0:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #2 from porten at kde dot org ---
The ICE is still there with current master
(f17d31e709af9b2d488adecd6cd040dfc1f23b04). The test case provided in bug
#114600 works for me now, though. So similar but seemingly no duplicate after
all.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
2024-04-21 22:17 ` [Bug c++/114795] " porten at kde dot org
2024-04-22 0:20 ` porten at kde dot org
@ 2024-04-22 1:52 ` nshead at gcc dot gnu.org
2024-04-22 7:37 ` porten at kde dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-22 1:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=114600,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99000
CC| |nshead at gcc dot gnu.org
--- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Similarly to PR114600 (and PR99000 and maybe some others?) this is because we
don't support textual redefinitions yet (`#include` after `import` naming the
same things). See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Modules.html:
G++’s modules support is not complete. Other than bugs, the known missing
pieces are:
[...]
Textual merging of reachable GM entities
Entities may be multiply defined across different header-units. These must
be de-duplicated, and this is implemented across imports, or when an import
redefines a textually-defined entity. However the reverse is not
implemented—textually redefining an entity that has been defined in an imported
header-unit. A redefinition error is emitted.
A workaround is to ensure that `#include` always goes before `import`, or to
use a header module here rather than `#include`.
FWIW this particular ICE is because we hit this assertion:
/* Don't add decls after definition. */
gcc_assert (TYPE_BEING_DEFINED (current_class_type)
/* We can add lambda types when late parsing default
arguments. */
|| LAMBDA_TYPE_P (TREE_TYPE (decl)));
but the class has already been defined earlier, by the import.
The other issue here is that we didn't discard the entire GMF here, I suppose
possibly because of a similar issue as described in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114630#c2.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (2 preceding siblings ...)
2024-04-22 1:52 ` nshead at gcc dot gnu.org
@ 2024-04-22 7:37 ` porten at kde dot org
2024-04-22 8:51 ` nshead at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22 7:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #4 from porten at kde dot org ---
Thanks for the reminder about the workaround. I had once seen it before trying
module but did not see the relation when running into problems later. In the
small test case, reordering the import and includes helps! It is just that the
original code base exposes another problem. In fact, the original one I
experienced:
/opt/gcc-14/include/c++/14.0.1/format: In member function ‘auto
std::__format::_Sink_iter<_CharT>::_M_reserve(std::size_t) const [with _CharT =
char]’:
/opt/gcc-14/include/c++/14.0.1/format:2632:7: error: invalid conversion in
return statement
2632 | _M_reserve(size_t __n) const
| ^~~~~~~~~~
<<< Unknown tree: template_type_parm >>>
struct _Reservation
return D.267932;
/opt/gcc-14/include/c++/14.0.1/format:2632:7: internal compiler error:
‘verify_gimple’ failed
0x138b51e verify_gimple_in_seq(gimple*, bool)
/home/porten/git/gcc/gcc/tree-cfg.cc:5318
[...]
If of any interest, I can try to reduce a test case preserving the error.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (3 preceding siblings ...)
2024-04-22 7:37 ` porten at kde dot org
@ 2024-04-22 8:51 ` nshead at gcc dot gnu.org
2024-04-22 22:49 ` porten at kde dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-22 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Thanks! That error message looks new to me, if you have a reproduction that
would be great.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (4 preceding siblings ...)
2024-04-22 8:51 ` nshead at gcc dot gnu.org
@ 2024-04-22 22:49 ` porten at kde dot org
2024-04-23 16:14 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-22 22:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #6 from porten at kde dot org ---
The test case for the other ICE is quite similar to the first one:
------------- command ------------
g++ -std=c++2a -fmodules-ts -c url.cpp queue.cpp
----------- url.cp ---------------
module;
#include <chrono>
export module url;
----------- queue.cpp -------------
#include <chrono>
import url;
#include <format>
void foo() { (void)std::format("bar"); }
--------- output --------------
In file included from /opt/gcc-14/include/c++/14.0.1/bits/chrono_io.h:39,
from /opt/gcc-14/include/c++/14.0.1/chrono:3360,
from queue.cpp:1:
/opt/gcc-14/include/c++/14.0.1/format: In member function ‘auto
std::__format::_Sink_iter<_CharT>::_M_reserve(std::size_t) const [with _CharT =
char]’:
/opt/gcc-14/include/c++/14.0.1/format:2632:7: error: invalid conversion in
return statement
2632 | _M_reserve(size_t __n) const
| ^~~~~~~~~~
<<< Unknown tree: template_type_parm >>>
struct _Reservation
return D.207483;
/opt/gcc-14/include/c++/14.0.1/format:2632:7: internal compiler error:
‘verify_gimple’ failed
0x138b51e verify_gimple_in_seq(gimple*, bool)
/home/porten/git/gcc/gcc/tree-cfg.cc:5318
0x10226ba gimplify_body(tree_node*, bool)
/home/porten/git/gcc/gcc/gimplify.cc:19234
0x1022876 gimplify_function_tree(tree_node*)
/home/porten/git/gcc/gcc/gimplify.cc:19352
0xe42f17 cgraph_node::analyze()
/home/porten/git/gcc/gcc/cgraphunit.cc:687
0xe45a77 analyze_functions
/home/porten/git/gcc/gcc/cgraphunit.cc:1251
0xe469fd symbol_table::finalize_compilation_unit()
/home/porten/git/gcc/gcc/cgraphunit.cc:2560
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (5 preceding siblings ...)
2024-04-22 22:49 ` porten at kde dot org
@ 2024-04-23 16:14 ` ppalka at gcc dot gnu.org
2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-23 16:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-04-23
CC| |ppalka at gcc dot gnu.org
--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reduced version of comment #6 testcase:
$ cat 114795_a.H
template<class T>
struct A {
auto f() { return 0; }
};
template<class T>
inline void g() {
A<int> a;
a.f();
}
$ cat 114795_b.C
template<class T>
struct A {
auto f() { return 0; }
};
A<int> a;
import "114795_a.H";
int main() {
g<int>();
}
$ g++ -fmodules-ts 114795_*
In module ./114795-2_a.H, imported at 114795_b.C:8:
114795_a.H: In instantiation of ‘void g() [with T = int]’:
114795_b.C:11:9: required from here
11 | g<int>();
| ~~~~~~^~
114795_a.H:9:6: error: use of ‘auto A<T>::f() [with T = int]’ before deduction
of ‘auto’
9 | a.f();
| ~~~^~
114795_a.H:9:6: error: use of ‘auto A<T>::f() [with T = int]’ before deduction
of ‘auto’
I think I have a fix -- we need to propagate an already-deduced return type
during deduplication.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (6 preceding siblings ...)
2024-04-23 16:14 ` ppalka at gcc dot gnu.org
@ 2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
2024-04-23 18:09 ` ppalka at gcc dot gnu.org
2024-04-24 7:15 ` porten at kde dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-23 18:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #8 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:4f9401d1a802325e5dfa2db841945e1a9c59a980
commit r14-10096-g4f9401d1a802325e5dfa2db841945e1a9c59a980
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Apr 23 14:01:22 2024 -0400
c++/modules: deduced return type merging [PR114795]
When merging an imported function template specialization with an
existing one, if the existing one has an undeduced return type and the
imported one's is already deduced, we need to propagate the deduced type
since once we install the imported definition we won't get a chance to
deduce it by normal means.
So this patch makes is_matching_decl propagate the deduced return
type alongside our propagation of the exception specification.
Another option would be to propagate it later when installing the
imported definition from read_function_def, but it seems preferable
to do it sooner rather than later.
PR c++/114795
gcc/cp/ChangeLog:
* module.cc (trees_in::is_matching_decl): Propagate deduced
function return type.
gcc/testsuite/ChangeLog:
* g++.dg/modules/auto-4_a.H: New test.
* g++.dg/modules/auto-4_b.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (7 preceding siblings ...)
2024-04-23 18:01 ` cvs-commit at gcc dot gnu.org
@ 2024-04-23 18:09 ` ppalka at gcc dot gnu.org
2024-04-24 7:15 ` porten at kde dot org
9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-23 18:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The "invalid conversion in return statement" error should hopefully be fixed
now.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/114795] internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot
2024-04-21 14:38 [Bug c++/114795] New: internal compiler error: in finish_member_declaration after module import in gcc 14.0.1 snapshot porten at kde dot org
` (8 preceding siblings ...)
2024-04-23 18:09 ` ppalka at gcc dot gnu.org
@ 2024-04-24 7:15 ` porten at kde dot org
9 siblings, 0 replies; 11+ messages in thread
From: porten at kde dot org @ 2024-04-24 7:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114795
--- Comment #10 from porten at kde dot org ---
It is! Even my original code base now fully compiles without errors. Thank you!
^ permalink raw reply [flat|nested] 11+ messages in thread