www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21151] New: div bug: long -5000 / size_t 2 =

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

          Issue ID: 21151
           Summary: div bug: long -5000 / size_t 2 = 9223372036854773308
           Product: D
           Version: D2
          Hardware: x86_64
               URL: http://dlang.org/
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mingwu gmail.com

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

--
Aug 13 2020