https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109889
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- With -std=c++14 there's no crash, with -std=c++17, so that confirms it's something related to copy elision.
redi at gcc dot gnu.org via Gcc-bugs Wed, 17 May 2023 08:57:39 -0700
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109889
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- With -std=c++14 there's no crash, with -std=c++17, so that confirms it's something related to copy elision.