jyknight wrote:

Here's a test case that clang diagnoses with `-Wundefined-inline` after this 
patch, which I'm not sure whether is correct or not. It might violate 
https://eel.is/c++draft/temp.inst#11 to attempt to instantiate the unused 
`S::operator int<int>`?

I'm having a hard time telling whether this code is ill-defined NDR, or if the 
compiler is required to accept this.

Clang stopped diagnosing this code with the fix for CWG2631, 
ca619613801233ef2def8c3cc7d311d5ed0033cb. Now this PR makes it diagnose again, 
despite that the default arg is never actually used.

```
struct S {
  template <typename T>
  consteval operator T();
};

struct M {
  int x = S();
};

void test(M m = {}) {}
```

```
test2.cc:3:13: error: inline function 'S::operator int<int>' is not defined 
[-Werror,-Wundefined-inline]
    3 |   consteval operator T();
      |             ^
test2.cc:7:11: note: used here
    7 |   int x = S();
      |           ^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/87933
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to