Types A!1 and A!1u not considered equal?

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 21 03:25:31 PDT 2011


On Friday, October 21, 2011 12:20:02 Tobias Brandt wrote:
> On 21 October 2011 10:01, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > On Friday, October 21, 2011 11:57:50 Gor Gyolchanyan wrote:
> >> That's because implicit casts in D are much more strict, then those in
> >> C/C++. Such seemingly intuitive cats, e.g. from long to int are not
> >> performed due to potential loss of data.
> >> Casting from int to uint has the same effect of potential loss of
> >> data.
> > 
> > In D, integral types implicitly convert to their unsigned counterparts
> > and vice versa. D does not consider those conversions to be narrowing
> > conversions which require a cast (though they _are_ narrowing
> > conversions and do risk messing up the number if it's too large or too
> > small).
> 
> Obviously, the conversion does happen implicitly, otherwise
> 'new A!1' wouldn't compile (A expects a uint as parameter).
> But then, why are A!1 and A!1u different types?

I believe that it's a bug in the compiler.

- Jonathan M Davis


More information about the Digitalmars-d mailing list