[Issue 24582] New: Detect unsafe casting to bool
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 3 13:06:20 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24582
Issue ID: 24582
Summary: Detect unsafe casting to bool
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
Given that only 0 and 1 are safe values:
https://dlang.org/spec/function.html#safe-values
Each of the casts below should fail.
void main() @safe
{
bool v = cast(bool) 2;
ubyte[] a = [2, 4];
auto b = cast(bool[]) a;
auto c = cast(bool[]) [2, 4]; // literal cast
}
PR incoming.
--
More information about the Digitalmars-d-bugs
mailing list