https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77686
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> --- Index: libstdc++-v3/include/std/functional =================================================================== --- libstdc++-v3/include/std/functional (revision 240521) +++ libstdc++-v3/include/std/functional (working copy) @@ -1418,7 +1418,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, t _Nocopy_types _M_unused; char _M_pod_data[sizeof(_Nocopy_types)]; - }; + } __attribute__((may_alias)); enum _Manager_operation { fixes this testcase. As std::swap takes reference args I suppose it should reliably work to prevent the issue.