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: [email protected]
          Reporter: [email protected]

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`.

--

Reply via email to