It is possible to substract 5 from 3 unsigned integer
Ali Çehreli
acehreli at yahoo.com
Tue Oct 6 15:12:25 UTC 2020
On 10/6/20 5:24 AM, Alaindevos wrote:
> Is that the expected behavior of the programmer?
> Opinions can differ. Feel free to elaborate.
The following is even more "expected". ;) Subtract zero from -1 and you
get size_t.max.
void main() {
int[] arr;
int i = -1;
auto u = (i - arr.length); // -1 - 0
assert(u == size_t.max); // the surprise
static assert (is (typeof(u) == size_t)); // the reason
}
Ali
More information about the Digitalmars-d-learn
mailing list