diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp index 1a9444d38fdd59..74413baf6fc0c9 100644 --- a/clang/lib/AST/Interp/EvalEmitter.cpp +++ b/clang/lib/AST/Interp/EvalEmitter.cpp @@ -152,7 +152,7 @@ template <> bool EvalEmitter::emitRet(const SourceInfo &Info) { // Implicitly convert lvalue to rvalue, if requested. if (ConvertResultToRValue) { - if (!Ptr.isDereferencable()) + if (!Ptr.isZero() && !Ptr.isDereferencable()) return false; // Never allow reading from a non-const pointer, unless the memory // has been created in this evaluation. diff --git a/clang/test/CodeGenCXX/nullptr.cpp b/clang/test/CodeGenCXX/nullptr.cpp index ca76c55e2122d1..0d8837b216bec1 100644 --- a/clang/test/CodeGenCXX/nullptr.cpp +++ b/clang/test/CodeGenCXX/nullptr.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s #include