[Issue 22715] New: compiler should issue warning when passing D:long as c_long to func.
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Jan 30 18:41:07 UTC 2022
    
    
  
https://issues.dlang.org/show_bug.cgi?id=22715
          Issue ID: 22715
           Summary: compiler should issue warning when passing D:long as
                    c_long to func.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mingwu at gmail.com
$ cat ldiv.d 
import std.stdio;
import core.stdc.stdlib;
void main() {
  long m = 24;
  long n = 111;
  ldiv_t qr = core.stdc.stdlib.ldiv(m, n);
  writeln(qr);
  assert(qr.quot == 0);
  assert(qr.rem  == 24);
}
$ dmd ldiv.d
$ ./ldiv 
ldiv_t(0, 0)
core.exception.AssertError at ldiv.d(10): Assertion failure
----------------
??:? _d_assertp [0x559c0455105d]
??:? _Dmain [0x559c045404f2]
of course, using lldiv(), we get the correct result:
lldiv_t(0, 24)
but:
1) the compiler should generate warning message, when user passing D:long as
c_long to ldiv().
2) both m and n in the above are small ints, even passing as long, why the
result is wrong? is there another hidden bug somewhere?
--
    
    
More information about the Digitalmars-d-bugs
mailing list