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: unassignedclangb...@nondot.org
Reporter: jva...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs