Signed-unsigned comparisons in Phobos

Don nospam at nospam.com
Fri Aug 12 02:37:13 PDT 2011


bearophile wrote:
> I have added this bit of code to my dmd, it gives warnings in cases of integral signed-unsigned comparisons:
> https://github.com/D-Programming-Language/dmd/pull/119
> 
> Then I have compiled Phobos (with unittests) with the -wi switch, this has generated some of those signed-unsigned warning messages, maybe this list is of interest for someone:
> http://codepad.org/Ku42j1SR
> 
> Note: that "ignored variadic arguments to the constructor" that lists no line number is generated at line 1766 of template ConstructorGeneratingPolicy() inside typecons.d Phobos module.
> 
> Bye,
> bearophile

I've had a look at a dozen or so of these, and they were all real. I 
didn't see any which require a cast to "make the compiler shut up".
That's pretty impressive. In C++ I find that such messages are nearly 
always false positives.

The one case where it's a bit annoying is this:

int [] x = new int[6]; // or x = some array literal.
for (int i = 0; i < x.length; ++i) {...}

Here is a suggestion for how we could eliminate such false positives.
http://d.puremagic.com/issues/show_bug.cgi?id=6478


More information about the Digitalmars-d mailing list