auto x = foo();
auto y = bar();
auto z = baz();
if (x - y > z) { ... }
This might be a bug, if one of these functions returns an
unsigned
type. Good luck finding that. Note that if all functions
return
unsigned, there isn't even any signed-unsigned mismatch.
I believe the correct statement, is "With only a bit of care
one can use
D's unsigned types for positive numbers and believe that one's
code is
correct, even though it contains subtle bugs."
Well I'm sorry but I quite disagree. -- Andrei
This might be a bug.
'Length' always needs to compare sizes. 'Width' and 'Height' like
it.
************************ dfl/drawing.d line:185 -218
**************************
///
Size opAdd(Size sz)
{
Size result;
result.width = width + sz.width;
result.height = height + sz.height;
return result;
}
///
Size opSub(Size sz)
{
Size result;
result.width = width - sz.width;
result.height = height - sz.height;
return result;
}
///
void opAddAssign(Size sz)
{
width += sz.width;
height += sz.height;
}
///
void opSubAssign(Size sz)
{
width -= sz.width;
height -= sz.height;
}
***********************end*************************
if the type of width and height are size_t,then their values
will be error.
small test:
-----------------------
import std.stdio;
void main()
{
size_t width = 10;
size_t height = 20;
writeln("before width is ",width," ,height is ",height);
height -= 1;
width -= height;
writeln("after width is ",width," ,height is ",height);
}
----------
"after width is " ERROR.