Bug 2467 – strtol() is improperly declared

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-11-22T05:04:00Z
Last change time
2015-11-03T19:16:41Z
Assigned to
nobody
Creator
davidell

Comments

Comment #0 by davidell — 2008-11-22T05:04:09Z
In dmd/src/phobos/std/c/stdlib.d, the following declaration is wrong: long strtol(char *,char **,int); /// ditto it should be declared with an 32-bit "int" return value. Declared as "long", whatever value EDX happens to have upon strtol()'s return gets stuffed into the upper 32-bits of a 64-bit return value. My test case demonstrates this: import std.stdio; import std.c.stdlib; void main(string[] args) { writefln("%x", strtol("55555555", null, 16)); assert(strtol("55555555", null, 16) == 0x55555555L); } The output is: 41ba3a55555555 Error: AssertError Failure a(5)
Comment #1 by andrej.mitrovich — 2011-05-24T22:28:54Z
Fixed long ago in core.stdc.stdlib.
Comment #2 by dlang-bugzilla — 2011-05-25T04:38:51Z
Please pay attention, this is a D1 bug which is still present in D1 Phobos.
Comment #3 by andrej.mitrovich — 2011-05-25T05:12:48Z
Yes, sorry I've closed some bugs which are D1-only by mistake. Apologies.
Comment #4 by andrei — 2015-11-03T19:16:41Z
It's unlikely this D1 issue will get worked on. If it applies to D2 as well and/or if anyone plans to work on it, please reopen.