ldc executable crashes with this code
Stanislav Blinov
stanislav.blinov at gmail.com
Fri Feb 4 15:58:19 UTC 2022
On Friday, 4 February 2022 at 11:26:42 UTC, forkit wrote:
> If I had wrote the code below, then I should not expect
> anything, whatsoever, from the compiler.
>
> () @trustMe_I_am_a_complete_idiot { char[] palindrome =
> cast(char[])"able was I ere I saw elba"; } ();
This is almost exactly what you have to do today, assuming you're
using @safe. You'll **have** to write this then:
`() @trusted { auto palindrome = cast(char[])"able was I ere I
saw elba"; } ();`
Instead, you opted to comment out `@safe`. Unfortunately, "@safe
by default" idea was brutally eviscerated.
As others have already stated, casting immutability away is
something that has to be supported, e.g. to interface with
const-agnostic APIs. `@safe` requires such casts to be more
verbose, with good reason.
More information about the Digitalmars-d-learn
mailing list