[clang] [Clang] Fail the constraint substitution early after CWG2369 (PR #143096)

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 12 02:59:39 PDT 2025


alexfh wrote:

@zyn0217 @cor3ntin should this case still work? I have troubles finding the relevant wording in the Standard. GCC and and Clang before this change used to accept this, MSVC fails similarly to Clang after this change (https://gcc.godbolt.org/z/Y79W533T3)

```
template <typename T>
concept HasSizeC = requires(T t) { t.size(); };
struct Builder {
  class C {
    friend Builder;
    void size();
  };
  template <HasSizeC F>
  void g(F);
  void f() { g(C{}); }
};
```

```
<source>:10:14: error: no matching member function for call to 'g'
   10 |   void f() { g(C{}); }
      |              ^
<source>:9:8: note: candidate template ignored: constraints not satisfied [with F = C]
    9 |   void g(F);
      |        ^
<source>:8:13: note: because 'Builder::C' does not satisfy 'HasSizeC'
    8 |   template <HasSizeC F>
      |             ^
<source>:2:38: note: because 't.size()' would be invalid: 'size' is a private member of 'Builder::C'
    2 | concept HasSizeC = requires(T t) { t.size(); };
      |                                      ^
```

https://github.com/llvm/llvm-project/pull/143096


More information about the cfe-commits mailing list