https://bugs.llvm.org/show_bug.cgi?id=38201
Bug ID: 38201
Summary: incorrect reinterpret_cast from integer to pointer
error on invalid constexpr initialization
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
The code is as follow:
struct S { int a, b; } s;
constexpr S *p = (S*)0;
constexpr const int *q = &p->b;
The code is invalid not because of a cast (there is none) but because it
attempts to use a null pointer to form the address of a member of an object.
clang++ accepts it. I checked g++. It rejects the code:
error: dereferencing a null pointer in '*0'
constexpr const int *q = &p->b;
^
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs