ldc executable crashes with this code

forkit forkit at gmail.com
Thu Feb 3 05:53:11 UTC 2022

On Thursday, 3 February 2022 at 03:25:39 UTC, H. S. Teoh wrote:
> On Thu, Feb 03, 2022 at 02:01:34AM +0000, forkit via 
> Digitalmars-d-learn wrote: [...]
>> would be nice if the compiler told me something though :-(
>> i.e. "hey, dude, you really wanna to that?"
> Mark your function @safe, and the compiler will stop you from 
> unsafe casts of this nature. That's part of the reason we have 
> @safe. ;-)
> T

so i mark all my modules as @safe, by default.

I commented it out though, so I could do the cast.

Then realised I didn't need the cast at all, just the .dup

now it's @safe again.

But @safe or not, nothing good can come from casting an immutable 
string to a mutable string, and the compiler really should know 
that ;-)

More information about the Digitalmars-d-learn mailing list