diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -150,6 +150,8 @@ case CK_IntegralToBoolean: case CK_IntegralCast: { + if (DiscardResult) + return this->discard(SubExpr); std::optional FromT = classify(SubExpr->getType()); std::optional ToT = classify(CE->getType()); if (!FromT || !ToT) diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -921,6 +921,9 @@ sizeof(int); alignof(int); + (short)5; + (bool)1; + return 0; } static_assert(ignoredExprs() == 0, "");