A strange div bug on Linux x86_64, (both dmd & ldc2): long -5000 / size_t 2 = 9223372036854773308
mw
mingwu at gmail.com
Thu Aug 13 07:22:18 UTC 2020
I post here because I think this bug's impact maybe pretty wide,
it's a div bug on Linux x86_64, (both dmd & ldc2). I'm
interested in knowing what caused this bug.
On Windows, I only tested dmd.exe, it correctly outputs -2500.
size_t: because I was taking array length, maybe many people do
that too.
https://issues.dlang.org/show_bug.cgi?id=21151
import std.stdio;
void main() {
long a = -5000;
size_t b = 2;
long c = a / b;
writeln(c);
}
$ dmd divbug.d
$ ./divbug
9223372036854773308
$ ldc2 divbug.d
$ ./divbug
9223372036854773308
x86_64 x86_64 x86_64 GNU/Linux
$ dmd --version
DMD64 D Compiler v2.092.0
$ ldc2 --version
LDC - the LLVM D compiler (1.21.0):
based on DMD v2.091.1 and LLVM 10.0.0
built with LDC - the LLVM D compiler (1.21.0)
Default target: x86_64-unknown-linux-gnu
Host CPU: bdver2
More information about the Digitalmars-d
mailing list