// https://godbolt.org/z/sxWY1f template<class P> concept C = requires (P ptr) { (struct D*)ptr; }; struct D {}; D d; ==== Clang accepts. GCC rejects; GCC's error messages imply that GCC is sometimes treating `D` as a class template `template<class P> struct D` and sometimes treating it as a normal class type, as if its internal representation is inconsistent. <source>:6:3: error: class template argument deduction failed: 6 | D d; | ^ <source>:6:3: error: no matching function for call to 'D()' <source>:3:40: note: candidate: 'template<class P> D()-> D' 3 | concept C = requires (P ptr) { (struct D*)ptr; }; | ^ <source>:3:40: note: template argument deduction/substitution failed: <source>:6:3: note: couldn't deduce template parameter 'P' 6 | D d; | ^ <source>:3:40: note: candidate: 'template<class P> D(D)-> D' 3 | concept C = requires (P ptr) { (struct D*)ptr; }; | ^ <source>:3:40: note: template argument deduction/substitution failed: <source>:6:3: note: candidate expects 1 argument, 0 provided 6 | D d; | ^ ==== I can also make GCC segfault by trying to use `D` as an NTTP, but I think that's essentially just a duplicate of #95159 #95291 #96123 #97749 etc., not necessarily related to the rejects-invalid bug described here. template<class P> concept C = requires (P ptr) { (struct D*)ptr; }; struct D { constexpr D(); }; template<D d> struct S {}; S<1> s;
It seems like it is creating a struct D with the template argument in the global namespace. If I add struct D; at the very begining of the file, it all works.
Seems to be fixed by r12-7997, so I suppose let's call this as dup of PR101677. *** This bug has been marked as a duplicate of bug 101677 ***