[Issue 18054] Wrong cast of float constant to bool

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 14 10:34:10 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=18054

--- Comment #4 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/dmd pull request #13421 "merge stable" was merged into master:

- 75b9a2334042d8b26055b6ad2bc4b7c3605411c5 by Florian:
  Fix 18054 - Use isBool instead of toInteger when const-folding cast(bool)
(#13285)

  `RealExp` / `ComplexExp` may hold values that don't have a matching
  integer value (unlike `IntegerExp`). Switching to `toBool` ensures
  proper boolean conversion according to the current type.

  The test output shown below (before this change) was caused by the
  invalid const-folding for floating point literals.

  ```
  float: 1 == 0
  double: 1 == 0
  real: 1 == 0
  ifloat: 1 == 0
  idouble: 1 == 0
  ireal: 1 == 0
  cfloat: 1 == 0
  cdouble: 1 == 0
  creal: 1 == 0
  ```

https://github.com/dlang/dmd/pull/13421

--


More information about the Digitalmars-d-bugs mailing list