https://bugs.llvm.org/show_bug.cgi?id=46308
Bug ID: 46308
Summary: Not a constant expression: comparison between unequal
pointers to void has unspecified result
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Keywords: compile-fail
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangb...@nondot.org
Reporter: language.law...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk
About the following program:
struct S
{
int i;
int j;
};
constexpr S s {};
static_assert(&s.i < (void*)&s.j);
clang in C++14, C++17 and C++2a modes says that the expression in static_assert
is not a constant expression:
$ clang++ prog.cc -std=c++14
prog.cc:9:15: error: static_assert expression is not an integral constant
expression
static_assert(&s.i < (void*)&s.j, "");
^~~~~~~~~~~~~~~~~~
prog.cc:9:20: note: comparison between unequal pointers to void has unspecified
result
static_assert(&s.i < (void*)&s.j, "");
^
(https://wandbox.org/permlink/IXwrV0M75To3wUUB)
However, the special handling of pointers to void has been removed from
[expr.rel] by http://wg21.link/n3624 (applied in [1]), so the result of
comparing unequal pointers to void is no longer unspecified, so the expression
is a constant expression.
[1]
https://github.com/cplusplus/draft/commit/89281b5795f47b9196c37ce8008b4873a76e90ef#diff-64a673ab7a20068092a4cf86b36f4334L3647-L3650
--
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