[Issue 2270] cast produces invalid arrays at runtime

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 11 09:03:17 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=2270


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #9 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-07-11 08:58:04 PDT ---
On a semi-related but not all that related note, I would point out to Steven
that Kenji has made pull requests related to std.conv.to, one of which will
make std.conv.to use opCast for user-defined conversions if a user-defined type
has an opCast, so if you don't think that opCast should be used for such
situations (that is, if you equate that to dangerous as you've been discussing
here), then you should comment on the pull request:

https://github.com/D-Programming-Language/phobos/pull/118
https://github.com/D-Programming-Language/phobos/pull/119
https://github.com/D-Programming-Language/phobos/pull/122

If no one else comments on those changes soon, they're likely to go in soon.
But they're giving a way to avoid having to use casts in your own code, so I
would think that they'd be an improvement, because then casts are used _less_
rather than more.

In any case, as for this particular bug, casts are definitely a blunt
instrument, so they tend to be legal whether you really want them to or not.
They're not quite as blunt as they are in C (e.g. they _do_ do checks when
converting between classes), but they're still pretty blunt. It's one of the
reasons that it's typically better to use std.conv.to rather than casting.

-- 
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