Implicit type conversions with data loss
Paul D. Anderson
paul.d.removethis.anderson at comcast.andthis.net
Tue Jun 5 11:17:48 PDT 2012
On Tuesday, 5 June 2012 at 18:06:15 UTC, ctrl wrote:
> I don't want them to be performed at all. How do I disable this
> 'feature'?
>
> For example, take a look at this code:
>
> import std.stdio;
> void main() {
> int x = -1;
> uint b = x;
> writeln(b);
> }
>
> It outputs 4294967295, but I want a compile-time error instead.
> Any suggestions?
> (compiler version dmd 2.059)
I doubt that a 'feature' that's been in D and it's predecessors
for such a long time is going to be easy to disable. Probably the
best you can do is to work with it: add an assert, perhaps, or
define a new type that checks for this condition.
Paul
More information about the Digitalmars-d
mailing list