[Issue 24646] New: `is` test broken for invalid bools
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 3 13:53:39 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24646
Issue ID: 24646
Summary: `is` test broken for invalid bools
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: qs.il.paperinik at gmail.com
The `is` binary operator (`lhs is rhs`) for built-in types should always test
the whole bit pattern of whatever it compares. For `bool` it tests only the
last bit of the `bool` value. This means that an invalid `bool` (e.g. created
by accident in `@system` code) is needlessly hard to debug. Bare-metal tools
such as `is` should be able to tell an invalid `bool` apart from a valid `bool`
by having an invalid bool be `!is true` and `!is false`, and instead have it
`is N` with 2 ≤ `N` ≤ `ubyte.max`.
--
More information about the Digitalmars-d-bugs
mailing list