Is this reasonable?

Jonathan M Davis jmdavisProg at gmx.com
Thu Dec 5 10:26:37 PST 2013


On Thursday, December 05, 2013 19:16:29 Maxim Fomin wrote:
> On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote:
> > Is this unavoidable, or could the compiler safely make the
> > conversion implicitly?
> 
> It is example of notorious phenomemena called "integer
> promotions" and "usual arithmetic conversions". It is unavoidable
> given Walter's decision to keep this C stuff in D.

To be fair, you can't solve the problem automatically. It's fundamentally 
wrong to compare signed and unsigned values, and doing either the conversion 
to unsigned or to signed could be wrong (or both could be wrong), depending on 
the values. The best that could be done would be to warn about the comparison 
or to make it an error.

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

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list