Skip to content

"as bool" does not properly convert its argument. #7311

Closed
@thomcc

Description

@thomcc

foo as bool should result in an i1, not an i8. This can lead to various unexpected or hard to debug behavior. See:

rusti> 3 as bool as u8
3
rusti> (3 as bool)
true
rusti> (2 as bool)
true
rusti> std::bool::xor(true, true)
false
rusti> std::bool::xor((3 as bool), (2 as bool))
true
rusti> 0xffff as bool as u8
255
rusti> 0xff00 as bool
false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions