[Issue 6912] const(T[])/immutable(T[]) can be implicitly cast to inout(const(T)[])/inout(immutable(T)[])
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 9 08:58:48 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6912
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|non-transitivity of inout |const(T[])/immutable(T[])
|breaks const system |can be implicitly cast to
| |inout(const(T)[])/inout(imm
| |utable(T)[])
--- Comment #2 from timon.gehr at gmx.ch 2011-11-09 08:58:10 PST ---
(In reply to comment #1)
> inout a = q;
>
> This line should fail to compile. const does not implicitly cast to inout.
>
Yes, but the issue here is that it casts to inout(const(int)[]). (dmd rejects
casting const(int[]) to inout(int[]) for exampe)
> Note that:
>
> immutable a = q;
>
> doesn't work. inout should follow the same restrictions.
>
> I don't think this has to do with transitivity (and indeed, inout cannot
> override const or immutable). It's just a simple case of inout cannot be
> implicitly cast from something else.
>
> Remember, inout can get implicitly cast back to immutable or mutable upon
> function return. I don't think inout should override *any* qualifiers without
> casts.
You are right, it is not a transitivity/overriding issue.
Currently inout(const(T)) == inout(immutable(T)) == inout(T). That is bad, for
example, how to represent the element type of inout(const(char)[]) ? (DMD
treats it as const(char), which is obviously wrong, it should be
inout(const(char)).)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list