Issue 178610
Summary clang reject valid code
Labels clang
Assignees
Reporter rockeet
    It is hard to describe this issue, the minimum reproduction code:

```c++
int test(int*);
template<class T>
struct A {
    template<class U>
    static auto f(U* p) ->
    decltype(test(p), A()) { return A(); }
};
template<class... Args>
auto g(Args&&... args)
->decltype(A<int>::f(args...)) {
    return A<int>::f(args...);
}
A<int> h(int* p) { return g(p); }
```

gcc is ok, see: https://godbolt.org/z/ehzezE75d

clang compile error:
```
<source>:6:23: error: invalid use of incomplete type 'A<int>'
 6 |     decltype(test(p), A()) { return A(); }
      | ^~~
<source>:10:12: note: in instantiation of template class 'A<int>' requested here
   10 | ->decltype(A<int>::f(args...)) {
      | ^
<source>:3:8: note: definition of 'A<int>' is not complete until the closing '}'
    3 | struct A {
      |        ^
<source>:10:20: error: no member named 'f' in 'A<int>'
   10 | ->decltype(A<int>::f(args...)) {
 |                    ^
<source>:11:20: error: no member named 'f' in 'A<int>'
   11 |     return A<int>::f(args...);
      | ^
<source>:13:27: error: no matching function for call to 'g'
   13 | A<int> h(int* p) { return g(p); }
      |                           ^
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to