<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/129986>129986</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Constexpr template member function call is not taken as a constant expression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
WorldRobertProject
</td>
</tr>
</table>
<pre>
class X
{
public:
constexpr X()
{
Foo(1);
}
template <typename T>
constexpr void Foo(T value)
{
}
};
constexpr X x;
The above code produces the following compilation error:
error: constexpr variable 'x' must be initialized by a constant expression
| constexpr X x;
| ^
note: undefined function 'Foo<int>' cannot be used in a constant expression
| Foo(1);
| ^
note: in call to 'X()'
| constexpr X x;
| ^
note: declared here
| constexpr void Foo(T value)
| ^
When Foo is a global function, no error occurs.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVMFy4ygQ_Rp06YpLQpYlHXRwnPV5aytVybWBtsUuAhUgJ9mvn8KWbWXKM4fhglDT771-NGAI-miJOlY9s-olwyn2zndvzhv1jxPk49_e_UsyZsKprw4AQBoMAd5Zvk0rVj_PX-MkjJas3Ka1dDZE-hw9vDPeMN7Om76nXMfeOcabIm0rn7_tfLnS5FuINIwGIwErd_FrJIsDwSsr_1pk3HlPTqsZ-BVOaCZ6qGJBUb_c2edpUQZ8XqIs3772BCjciUA6RTB6pyZJAWJPcHDGuA9tjyDdMGqDUTsL5L3zF2tm5OufpWL0GoUhYLz-ZLyGYQoRBIG2Omo0-n9SIL4ALzloI6Q8CkE7eyti90j0NbQcrDobZ12kpGOyig7akoLDZOVZNeN1MrDcaRuTzbwGida6s6gpkAJtf61myffogJfxWQvATY62INEYiC7JuDYRr_-4zgW2ImnQk4KePD0E_F3z_Iz_jYbl27eebMoFHQDhaJxAc_OU8R1Ydzl9cFJOPqxYvs1UV6q2bDGjrqjXBS_roqqyvstrkVeiwIZoQ3VTtlJsGtmKBpVqxabJdMdzXuVlvsnXVVtUK9wULRdVIbGpREUHts5pQG1WxpyGlfPHTIcwUVfwtm02mUFBJpyvP-eWPuAcZZyn18B3KelJTMfA1rnRIYY7TNTRULe7eXa7ngMNgvy9jc7nqEOyHyL-RxYwPG6bbPKm62McQ7orfM_4_qhjP4mVdAPj-8Q9T0_j5V1ifH9WHBjfzyWdOv4jAAD__8wsbjE">