Skip to content

Commit d8f0611

Browse files
committed
[clang][Interp] Allow ltor casts for null pointers
We can't read from them but we special-case them later.
1 parent e140a8a commit d8f0611

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

clang/lib/AST/Interp/EvalEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
152152

153153
// Implicitly convert lvalue to rvalue, if requested.
154154
if (ConvertResultToRValue) {
155-
if (!Ptr.isDereferencable())
155+
if (!Ptr.isZero() && !Ptr.isDereferencable())
156156
return false;
157157
// Never allow reading from a non-const pointer, unless the memory
158158
// has been created in this evaluation.

clang/test/CodeGenCXX/nullptr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
23

34
#include <typeinfo>
45

0 commit comments

Comments
 (0)