https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126223
Kirkezz <iamkirkezz at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |iamkirkezz at gmail dot com
--- Comment #3 from Kirkezz <iamkirkezz at gmail dot com> ---
A smaller C++20 example without operator<=>.
A defaulted hidden-friend operator== on a plain aggregate
is enough, with no headers.
// m.cppm
export module m;
export struct s {
int a, b;
friend constexpr bool operator==(s, s) = default;
};
// u.cpp
import m;
int main() { return s{1, 2} == s{1, 2} ? 0 : 1; }
$ g++ -std=c++20 -fmodules -fmodule-mapper='|@g++-mapper-server?mods' -c
m.cppm -o m.o
$ g++ -std=c++20 -fmodules -fmodule-mapper='|@g++-mapper-server?mods' -c
u.cpp -o u.o
In module m, imported at u.cpp:1:
m.cppm:5:27: internal compiler error: Segmentation fault
5 | friend constexpr bool operator==(s, s) = default;
| ^~~~~~~~
0x219844c internal_error(char const*, ...)
gcc/diagnostic-global-context.cc:787
0x102de0f crash_signal
gcc/toplev.cc:325
0x8bf6e1 module_state::mangle(bool)
gcc/cp/module.cc:16692
0x89f84c write_module
gcc/cp/mangle.cc:1018
0x89f84c maybe_write_module
gcc/cp/mangle.cc:1035
Scope, all on the 16.1.0 release tarball (x86_64-pc-linux-gnu):
friend constexpr bool operator==(s, s) = default; ICE
same without constexpr ICE
friend bool operator==(const s&, const s&) = default; ICE
friend auto operator<=>(s, s) = default; ICE
-std=c++20 / -std=c++23 / -std=c++26 ICE in all three
member form: bool operator==(const s&) const = default; ok
hand-written friend body ok
So the trigger is: defaulted + hidden friend + declared in a class exported
from a named module + odr-used by an importer.
Given -std=c++20 reproduces the bug with the same stacktrace, the c++26
keyword may be worth dropping.