On 02/11/2014 20:33, Walter Bright wrote:
On 11/2/2014 12:12 PM, bearophile wrote:
I think the free mixing of signed and unsigned integral values is not
a good
idea in D.
It's simply not workable to put a wall between them. Every proposal for
it has entailed various unfortunate, ugly, and arbitrary consequences.
We need warnings like gcc has:
"-Wsign-compare
Warn when a comparison between signed and unsigned values could
produce an incorrect result when the signed value is converted to unsigned.
-Wconversion
Warn for implicit conversions that may alter a value. This includes
... conversions between signed and unsigned, like unsigned ui = -1 ...
Warnings about conversions between signed and unsigned integers can be
disabled by using -Wno-sign-conversion.
"
It is really unfortunate that D is more bug-prone than gcc in this case.
There was some promising work here:
https://github.com/D-Programming-Language/dmd/pull/1913