https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104652
--- Comment #2 from Vorfeed Canal <vorfeed.canal at gmail dot com> --- Thanks for showing a workaround: class Foo { public: explicit Foo(int f) : x(f) {} [[gnu::target("default")]] friend inline Foo bar(Foo& foo) { return Foo(foo.x); } [[gnu::target("sse4.2")]] friend inline Foo bar(Foo& foo) { return Foo(foo.x * 2); } private: int x; }; It works perfectly with Clang, ICC and GCC 11, but GCC 12 breaks it: https://godbolt.org/z/fxb5ecea8 Is it possible to unbreak it? Because now it's a regression.