https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77879
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 39763 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39763&action=edit patch <bb 24>: _73 = MEM[(long unsigned int *)&home + 8B]; _74 = MEM[(char * *)&home]; D.32906 = PathTraitsFS::Build (_74, _73, ".config", 7); [return slot optimization] <bb 25>: MEM[(struct _Alloc_hider *)&fallback]._M_p = &MEM[(struct basic_string *)&fallback].D.17830._M_local_buf; _76 = MEM[(char * *)&D.32906]; if (&D.32906.D.17830._M_local_buf == _76) goto <bb 26>; else goto <bb 27>; this is the condition that is optimized. _76 points to nonlocal/escaped. Looks like a PTA bug, mishandled RSO in some way. Ah, RSO handling is missing from pure/const fn handling. Can you try if the attached fixes the issue?