Bug 22715 – compiler should issue warning when passing D:long as c_long to func.

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-01-30T18:41:07Z
Last change time
2024-12-13T19:20:40Z
Assigned to
No Owner
Creator
mw
See also
https://issues.dlang.org/show_bug.cgi?id=18117
Moved to GitHub: dmd#18081 →

Comments

Comment #0 by mingwu — 2022-01-30T18:41:07Z
$ 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) [email protected](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?
Comment #1 by duser — 2022-02-19T05:47:28Z
> 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? that would be this issue: https://issues.dlang.org/show_bug.cgi?id=18117
Comment #2 by robert.schadek — 2024-12-13T19:20:40Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18081 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB