[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 5 00:38:01 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.cpp:487
+  if (S.inConstantContext())
+    return true;
+
----------------
jcranmer-intel wrote:
> Not sure I understand the conditions that cause `S.inConstantContext()` to be true, which gives me some cause for concern. Additionally, there's no tests covering the checks in the function.
This function is almost copy/paste from `checkFloatingPointResult` in `ExprConstant.cpp`: https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ExprConstant.cpp#L2581


================
Comment at: clang/lib/AST/Interp/Opcodes.td:502
+  let Types = [AluTypeClass];
+  let Args = [ArgFltSemantics];
+  let HasGroup = 1;
----------------
jcranmer-intel wrote:
> Integer-to-floating point conversion is dependent on rounding mode--consider `(float)UINT_MAX`.
This test succeeds here, whether I use `-frounding-math` or not:

```
constexpr float f = (float)4294967295;
static_assert(f == (float)4.2949673E+9);
```
How can I test this behavior?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134859/new/

https://reviews.llvm.org/D134859



More information about the cfe-commits mailing list