dmd/changelog/dmd.unsafe-boolean-values.dd
Nick Treleaven 6c6a89e79f
[stable] Update changelog for unsafe bool values (#16560)
* Update changelog for unsafe bool values

* Casting to bool is actually safe
2024-06-04 10:35:53 +03:00

12 lines
589 B
Text

`bool` values other than 0 or 1 are not `@safe`
The spec has been updated so that only 0 and 1 are
[safe values](https://dlang.org/spec/function.html#safe-values)
for `bool`. This means that reading a `bool` value whose underlying byte representation
has other bits set is implementation-defined and should be avoided. Consequently:
* `void` initialization of booleans is now deprecated in `@safe` code.
* Reading a `bool` field from a union is now deprecated in `@safe` code.
Runtime array casting to `bool[]` is
[yet to be deprecated](https://issues.dlang.org/show_bug.cgi?id=24582).