www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15605] New: Invalid result of ptrdiff_t comparison.

https://issues.dlang.org/show_bug.cgi?id=15605

          Issue ID: 15605
           Summary: Invalid result of ptrdiff_t comparison.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: keepitsimplesirius gmail.com

import std.stdio;


void func(size_t w, size_t h) {
    ptrdiff_t a = h / 2;
    ptrdiff_t b = h / 2;

    writeln(-a, " ", -a + w);
    writeln(-a < -a + w);
}


int main() {
    func(3, 3);

    return 0;
}

Outputs:
-1 2
false


Should:
-1 2
true

Compiler:
DMD64 D Compiler v2.069.2
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright

--
Jan 25