| Issue |
63892
|
| Summary |
[Clang] Consteval and static method call leads to error
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
ndiogen
|
Hi! It seems that I`ve met clang bug when trying to call static method using dot operator.
GCC and MSVC compiles this code ok, but CLANG fails, unfortunately
```
template <unsigned TValue>
class Foo
{
public:
static consteval unsigned getSize()
{
return TValue;
}
};
unsigned SumOK( Foo<4> a )
{
unsigned s = 0;
s += a.getSize();
return s;
}
unsigned SumFAIL( Foo<4>& a )
{
unsigned s = 0;
s += a.getSize(); // Error here
return s;
}
int main() {
}
```
```
<source>:25:10: error: call to consteval function 'Foo<4>::getSize' is not a constant _expression_
s += a.getSize(); // Error here
^
<source>:25:10: note: function parameter 'a' with unknown value cannot be used in a constant _expression_
<source>:22:27: note: declared here
unsigned SumFAIL( Foo<4>& a )
^
1 error generated.
Compiler returned: 1
```
https://godbolt.org/z/P8xvaP6Kf - compiler explorer
Thank you!
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs