Issue |
83979
|
Summary |
Clang rejects call to base class member function inside requires inside constexpr if using scope resolution operatot
|
Labels |
clang
|
Assignees |
|
Reporter |
ranaanoop
|
The following program is rejected by clang :[Demo](https://godbolt.org/z/34ra7aM1s)
```
#include<type_traits>
template<typename T>
struct AlwaysFalse : public std::false_type {};
struct B
{
template<typename S>
void foo(){}
};
template <typename T,typename S>
struct A:T
{
auto foo(){
if constexpr (requires{T::template foo<S>();})
return 1;
else
static_assert(AlwaysFalse<A>::value,
"foo is not implemented.");
}
};
int main()
{
A<B,double> a;
a.foo();
}
```
Clang says:
```
<source>:19:22: error: static assertion failed due to requirement 'AlwaysFalse<A<B, double>>::value': foo is not implemented.
19 | static_assert(AlwaysFalse<A>::value,
| ^~~~~~~~~~~~~~~~~~~~~
<source>:27:3: note: in instantiation of member function 'A<B, double>::foo' requested here
27 | a.foo();
| ^
1 error generated.
Compiler returned: 1
```
---
Note program work if we change constexpr if to `if constexpr (requires(T t){t. template foo<S>();})`. [Demo](https://godbolt.org/z/jKGfenq1o)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs