<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - templated constexpr variable fails to deduce auto type in template context"
href="https://bugs.llvm.org/show_bug.cgi?id=49998">49998</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>templated constexpr variable fails to deduce auto type in template context
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pro.guillaume.dua@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Using clang 12.0.0
Note : Maybe in correlation with <a class="bz_bug_link
bz_status_CONFIRMED "
title="CONFIRMED - templated constexpr constant in a template fails to deduce auto type"
href="show_bug.cgi?id=43459">https://bugs.llvm.org/show_bug.cgi?id=43459</a>
Looks like Clang cannot evaluate an `auto` type for a constexpr
template-variable which depends on another,
when both depends on a template context.
See live example here on godbolt : <a href="https://godbolt.org/z/ofveeGoWe">https://godbolt.org/z/ofveeGoWe</a>
```cpp
template <typename ... Ts>
struct foo
{
constexpr inline static auto value = 42;
};
template <typename ... Ts>
struct bar
{
template <typename U>
constexpr static inline auto foo_value = foo<Ts...>::value; // KO
// nb : replacing `auto` with `int` remove the error
};
static_assert(bar<int>::foo_value<int> == 42);
```
Which results in :
```log
<source>:15:40: error: invalid operands to binary expression ('const auto' and
'int')
```
Stackoverflow associated post :
<a href="https://stackoverflow.com/questions/67127710/clang-invalid-operands-to-binary-expression-const-auto-and-int-with-cons">https://stackoverflow.com/questions/67127710/clang-invalid-operands-to-binary-expression-const-auto-and-int-with-cons</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>