<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123052>123052</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Call to consteval method from constexpr constructor makes constructor consteval.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
IViktorov
</td>
</tr>
</table>
<pre>
```C++
#include <cstdint>
#include <print>
template <class T, std::size_t kSize>
struct Test {
constexpr Test(const Test& t) noexcept: m_data{t.data()}, m_size{t.size()} {}
constexpr Test(T (&data)[kSize]) noexcept: m_data{data}, m_size{kSize} {}
constexpr T* data() const noexcept { return m_data; }
#ifdef NOCONSTEVAL
constexpr static std::size_t size() noexcept { return kSize; }
#else
consteval static std::size_t size() noexcept { return kSize; }
#endif
private:
T* m_data;
std::size_t m_size;
};
int main() {
int arr[] = {1, 2, 3, 4, 5, 6};
Test t1{arr};
Test t{t1};
std::println("arr[0] = {}, arr size = {}.", *t.data(), t.size());
}
```
With `consteval size()` method `Test` copy constructor becomes immediate function, but it should not.
Without consteval with `constexpr size()` everything goes as expected.
GCC doesn't have that problem with consteval methods, called in contructors.
https://godbolt.org/z/P157TafW8
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2PozgQ_TXmUpoI7ADJgUOSnqxWWs2sNNHMsWWgErxtMLKLTHf_-pVtOh-T3dtIljFV1HvP9YF0Tp0GxIrlW5Y_JXKiztjqz-_qhYw156Q27VvFijSuHeNbv9IN40INjZ5aBCZ2jaNWDcTE5wfXaK-Oj0XYj1pSDNXSOTgwvgNHLRMbJjZOveMzwcs39Y4x1JGdGoIDOgJWegHQmMERvo42WBlfBcP8UgAxvobB4GuDIzGxgf65lSRZuaVFOPAV42tWPnnm_tlTBl84fPgCV_nk6QAeGQ8Qviwi3prl2yg5f_pf8vi4J41Bt2yPhIxv4Co7ei4MPhAs0mSHDyaxh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