<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 - Unclear error message shadowing/init with itself; should possibly be another compiler error"
href="https://bugs.llvm.org/show_bug.cgi?id=43265">43265</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unclear error message shadowing/init with itself; should possibly be another compiler error
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jvapen@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>// clang-cl.exe /nologo /c -Weverything /GR /EHsc t.cpp
enum class E {
A = 1
};
template <E e> struct C { static constexpr E e = e; /*shadowing!*/ };
template <class C> void g() { static_assert(C::e == E::A); }
void f() { g< C<E::A> >(); }
<span class="quote">>> Error: (both 7.0.0 as 9.0.0-RC3)</span >
t.cpp(7,31): error: static_assert failed due to requirement 'C<E::A>::e ==
E::A'
template <class C> void g() { static_assert(C::e == E::A); }
^ ~~~~~~~~~~~~
Looking at the code above, I've found out that the initialization of
static constexpr E e = e;
is actually initializing with zero initialization followed by initializing with
itself?
The error was not that obvious without the reduction.
I see multiple issues:
- the template 'e' is shadowing the constexpr 'e' -> We don't get a warning on
this
- constexpr 'e' is being initialized with a value not in the enumeration ->
not sure if this is an error (is it UB?), however, it at least deserves a
warning (I'm pretty sure I already saw it at another place)
- Bonus points: Can we, similar to the template arguments, get some 'aka' for
nummerics/types used: example: static_assert(0 == 1);</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>