Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -165,14 +165,16 @@ } case CK_PointerToBoolean: { + PrimType PtrT = classifyPrim(SubExpr->getType()); + // Just emit p != nullptr for this. if (!this->visit(SubExpr)) return false; - if (!this->emitNullPtr(CE)) + if (!this->emitNull(PtrT, CE)) return false; - return this->emitNEPtr(CE); + return this->emitNE(PtrT, CE); } case CK_ToVoid: Index: clang/test/AST/Interp/functions.cpp =================================================================== --- clang/test/AST/Interp/functions.cpp +++ clang/test/AST/Interp/functions.cpp @@ -176,6 +176,13 @@ constexpr S s{ 12 }; static_assert(s.fp == nullptr, ""); // zero-initialized function pointer. + + constexpr int (*op)(int, int) = add; + constexpr bool b = op; + static_assert(op, ""); + static_assert(!!op, ""); + constexpr int (*op2)(int, int) = nullptr; + static_assert(!op, ""); } namespace Comparison {