ldc executable crashes with this code
forkit
forkit at gmail.com
Fri Feb 4 11:26:42 UTC 2022
On Friday, 4 February 2022 at 10:09:22 UTC, Patrick Schluter
wrote:
> On Thursday, 3 February 2022 at 02:01:34 UTC, forkit wrote:
>> On Thursday, 3 February 2022 at 01:57:12 UTC, H. S. Teoh wrote:
>>>
>>
>> would be nice if the compiler told me something though :-(
>>
>> i.e. "hey, dude, you really wanna to that?"
>
> would be nice if programmers (C or D) learnt that a typecast
> means "shut up compiler I know what I do". You explicitly
> instructed the compiler to not complain.
>
> Remove the typecast and the compiler will bring an error.
>
> That's the reason why typecasts are to be avoided as much as
> possible.It is often a code smell.
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"; } ();
More information about the Digitalmars-d-learn
mailing list