Bug 15605 – Invalid result of ptrdiff_t comparison.
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-01-25T17:15:00Z
Last change time
2016-01-26T11:08:28Z
Assigned to
nobody
Creator
keepitsimplesirius
Comments
Comment #0 by keepitsimplesirius — 2016-01-25T17:15:13Z
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
Comment #1 by keepitsimplesirius — 2016-01-25T19:04:12Z
Well, after more investigation it seems that it is not a bug. There is implicit conversion from signed to unsigned that causes that behavior. I wast too hasty with reporting that... Is there a way to remove the issue?
Comment #2 by ag0aep6g — 2016-01-25T19:10:23Z
(In reply to keepitsimplesirius from comment #1)
> Is there a way to remove the issue?
Just change the status to RESOLVED INVALID (below the comment text box).