[Issue 21583] `array` is not `@safe` for a certain combination of `iota` and data types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 2 10:59:46 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21583

Berni44 <bugzilla at bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at bernis-buecher.de

--- Comment #1 from Berni44 <bugzilla at bernis-buecher.de> ---
The reason is the cast() here:

emplaceRef!(Unqual!T)(bigData[len], cast() item);

found in std.array:

https://github.com/dlang/phobos/blob/a1ee4fd4fd02529f5849e317fe9eccb8280f4b37/std/array.d#L3466

(Error: cast from `const(Block)` to `Block` not allowed in safe code)



If it is replaced by 

emplaceRef!(Unqual!T)(bigData[len], () @trusted { return cast() item; }() );

the example works. But I'm not sure if I want to trust that cast...

--


More information about the Digitalmars-d-bugs mailing list