[llvm-bugs] [Bug 37593] New: clang: diagnostics about constexpr misuse are nonexistant
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 25 13:59:19 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37593
Bug ID: 37593
Summary: clang: diagnostics about constexpr misuse are
nonexistant
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: lebedev.ri at gmail.com
CC: llvm-bugs at lists.llvm.org
https://godbolt.org/g/8jgtJU
struct A {
struct B;
static const B c;
template <const B& d>
static void theWork();
};
struct A::B {
int e;
explicit constexpr B(int e_) : e(e_) {}
};
constexpr auto A::c = A::B(0);
template <const A::B& d>
void A::theWork() {
static_assert(d.e == 0, "can't stop the work!");
}
int main(int argc, char* argv[]) {
A::theWork<A::c>();
return 0;
}
clang happily accepts that code.
gcc chokes on it:
<source>:14:19: error: conflicting declaration 'constexpr const auto A::c'
constexpr auto A::c = A::B(0);
^
<source>:3:20: note: previous declaration as 'const A::B A::c'
static const B c;
^
<source>: In instantiation of 'static void A::theWork() [with const A::B& d =
A::c]':
<source>:22:22: required from here
<source>:18:23: error: non-constant condition for static assertion
static_assert(d.e == 0, "can't stop the work!");
~~~~^~~~
<source>:18:23: error: the value of 'A::c' is not usable in a constant
expression
<source>:3:20: note: 'A::c' was not declared 'constexpr'
static const B c;
^
Compiler returned: 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/20180525/48f0f124/attachment.html>
More information about the llvm-bugs
mailing list