[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)
Mital Ashok via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 29 02:52:31 PDT 2024
================
@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
if (Result.isInvalid())
return Result;
- // Check for a narrowing implicit conversion.
+ if (SCS->Second == ICK_Floating_Conversion) {
----------------
MitalAshok wrote:
Because it has a different specification from narrowing conversions (<https://wg21.link/expr.const#13.9> vs <https://wg21.link/dcl.init.list#7.2>), so we need stuff specific for converted constant expressions. E.g., `float{__FLT_DENORM_MIN__ / 4.0}` is not a narrowing conversion even though it rounds the double value to `0.0f`, but it shouldn't be a converted constant expression.
Theoretically we should only be calling `getNarrowingKind` when `SCS->Second == ICK_Integral_Conversion` (I think we also use it for boolean conversions [CWG1407](https://cplusplus.github.io/CWG/issues/1407.html)).
https://github.com/llvm/llvm-project/pull/90387
More information about the cfe-commits
mailing list