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: unassignedclangb...@nondot.org
Reporter: zhong...@pku.org.cn
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
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
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs