Why is this not a warning?

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 16 14:50:38 PDT 2016


On Wednesday, 16 March 2016 at 16:40:49 UTC, Shachar Shemesh 
wrote:
> ...
>
> People who are marginally familiar with integer promotion will 
> not be surprised to know that the program prints "256". What is 
> surprising to me is that this produced neither error nor 
> warning.
>
> The comparable program in C++, when compiled with gcc, 
> correctly warns about signed/unsigned comparison (though, to be 
> fair, it seems that clang doesn't).

While this particular issue can and should be addressed in the 
compiler (see my other reply), in the mean time how about trying 
out my `checkedint` DUB package?

It fixes the signed/unsigned mess, and many other similar 
problems, such as integer overflow:
     https://code.dlang.org/packages/checkedint
My intention is to submit it for inclusion in Phobos some time 
soon.

Note that because of various flakiness with DMD, it sort of 
requires LDC or GDC at the moment.


More information about the Digitalmars-d mailing list