Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -231,7 +231,8 @@ return this->emitNEPtr(CE); } - case CK_IntegralComplexToBoolean: { + case CK_IntegralComplexToBoolean: + case CK_FloatingComplexToBoolean: { std::optional ElemT = classifyComplexElementType(SubExpr->getType()); if (!ElemT) @@ -246,8 +247,14 @@ return false; if (!this->emitLoadPop(*ElemT, CE)) return false; - if (!this->emitCast(*ElemT, PT_Bool, CE)) - return false; + if (*ElemT == PT_Float) { + if (!this->emitCastFloatingIntegral(PT_Bool, CE)) + return false; + } else { + if (!this->emitCast(*ElemT, PT_Bool, CE)) + return false; + } + // We now have the bool value of E[0] on the stack. LabelTy LabelTrue = this->getLabel(); if (!this->jumpTrue(LabelTrue)) @@ -259,8 +266,13 @@ return false; if (!this->emitLoadPop(*ElemT, CE)) return false; - if (!this->emitCast(*ElemT, PT_Bool, CE)) - return false; + if (*ElemT == PT_Float) { + if (!this->emitCastFloatingIntegral(PT_Bool, CE)) + return false; + } else { + if (!this->emitCast(*ElemT, PT_Bool, CE)) + return false; + } // Leave the boolean value of E[1] on the stack. LabelTy EndLabel = this->getLabel(); this->jump(EndLabel); Index: clang/test/AST/Interp/complex.cpp =================================================================== --- clang/test/AST/Interp/complex.cpp +++ clang/test/AST/Interp/complex.cpp @@ -66,4 +66,11 @@ static_assert(F5, ""); constexpr _Complex unsigned char F6 = {0, 0}; static_assert(!F6, ""); + + constexpr _Complex float F7 = {0, 1}; + static_assert(F7, ""); + constexpr _Complex float F8 = {1, 0}; + static_assert(F8, ""); + constexpr _Complex double F9 = {0, 0}; + static_assert(!F9, ""); }