<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63892>63892</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Consteval and static method call leads to error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ndiogen
</td>
</tr>
</table>
<pre>
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!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslUtv2zgQxz8NfRnEoEhblg86OHLUDdrdLZCid0ocS9xQpMGH0_TTLyg5sp19FIutIFAPkvP_cTicEd6rziCWZH1P1vuFiKG3rjRS2Q7NorHytfxFEZbBYwCPOHgIvQjwSHJ6QoABA7RamA6a2MFLjwaCe1Wmg2ChFVqDDyKoNg3srYToU5-0AewRnQjWLQndE7r7UFUgjIRfn75W0NrhqDQmLeWhtRLBPhNWQRMDVJ92v32Ag1Dap1_RHKwL0YiA-nWydW5zer7Hz4DDUYuAQHgVzbhqCV--Ch2R8IdpTKuF91Bbe7awuZ9ejrHRqiX8bBkA3pbVWuMDnoSG2WaH4Ul9R8IKwraXCbMxOF8OQ3RmRri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