https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95606
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- The testcase is: #include <any> #include <string> template<typename> class basic_json; using json = basic_json<std::string>; class json_ref { public: template <typename T, bool = std::is_constructible<json, T>::value> json_ref(T &&){} }; template<typename> class basic_json { public: basic_json(json_ref) {} }; namespace std { template<> void swap<json>(json&, json&) noexcept {} } int main() {} This fails when compiled with -std=gnu++17 or later. Specializing std::swap like this is wrong (and in C++20 explicitly results in undefined behaviour). Replacing it with a normal overload in the same namespace as the type avoids the error. Do you have an example that doesn't involve a bogus specialization in namespace std?