[Issue 24582] Detect unsafe `cast(bool[])`
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jun  3 19:31:30 UTC 2024
    
    
  
https://issues.dlang.org/show_bug.cgi?id=24582
--- Comment #3 from Nick Treleaven <nick at geany.org> ---
    bool v = cast(bool) 2;
    ubyte[] a = [2, 4];
    auto b = cast(bool[]) a;
    auto c = cast(bool[]) [2, 4]; // literal cast
    import std.stdio;
    writeln(*cast(byte*)&v); // 1, OK
    writeln(*cast(byte*)b.ptr); // 2, unsafe
    writeln(*cast(byte*)c.ptr); // 1, OK
So only the runtime array cast is unsafe.
--
    
    
More information about the Digitalmars-d-bugs
mailing list