Why implicit conversion of string literal to char[] does not works?
Michal Minich
michal.minich at gmail.com
Tue Jul 2 08:20:04 PDT 2013
On Tuesday, 2 July 2013 at 14:26:54 UTC, Jesse Phillips wrote:
> On Tuesday, 2 July 2013 at 13:51:15 UTC, Michal Minich wrote:
>> As this cast (on linux), will _allways_ result in undefined
>> behavior. It is something compiler can easily tell, and
>> advice "use .dup instead of cast..."
>
> Casting away const/immutable is not undefined, modifying
> const/immutable data is. Since you cast away immutable the
> compiler can no longer prevent you from making such
> modifications.
You are right, the cast itself will not result in undefined
behavior. But it might give you value on which any write
operation will. So why not warn programer of such behavior when
we can know it statically.
More information about the Digitalmars-d-announce
mailing list