[llvm-bugs] [Bug 43265] New: Unclear error message shadowing/init with itself; should possibly be another compiler error
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 10 09:34:59 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43265
Bug ID: 43265
Summary: Unclear error message shadowing/init with itself;
should possibly be another compiler error
Product: clang
Version: 9.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jvapen at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
// 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> >(); }
>> Error: (both 7.0.0 as 9.0.0-RC3)
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);
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190910/8e23aabf/attachment.html>
More information about the llvm-bugs
mailing list