diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 241d5941e143e..13e004371f912 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1680,7 +1680,7 @@ bool CastFloatingIntegral(InterpState &S, CodePtr OpPC) { auto Status = F.convertToInteger(Result); // Float-to-Integral overflow check. - if ((Status & APFloat::opStatus::opInvalidOp) && F.isFinite()) { + if ((Status & APFloat::opStatus::opInvalidOp)) { const Expr *E = S.Current->getExpr(OpPC); QualType Type = E->getType(); diff --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp index 2c28e53784c5c..000ffe39eb94a 100644 --- a/clang/test/AST/Interp/cxx20.cpp +++ b/clang/test/AST/Interp/cxx20.cpp @@ -765,3 +765,12 @@ namespace FailingDestructor { f(); // both-error {{no matching function}} } } + + +void overflowInSwitchCase(int n) { + switch (n) { + case (int)(float)1e300: // both-error {{constant expression}} \ + // both-note {{value +Inf is outside the range of representable values of type 'int'}} + break; + } +}