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

Reply via email to