Thread overview
[Issue 2467] New: strtol() is improperly declared
Nov 22, 2008
d-bugmail
May 25, 2011
Andrej Mitrovic
May 25, 2011
Vladimir Panteleev
May 25, 2011
Andrej Mitrovic
November 22, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2467

           Summary: strtol() is improperly declared
           Product: D
           Version: 1.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: davidell@earthling.net


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)


-- 

May 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2467


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-24 22:28:54 PDT ---
Fixed long ago in core.stdc.stdlib.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2467


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-05-25 04:38:51 PDT ---
Please pay attention, this is a D1 bug which is still present in D1 Phobos.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2467



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-25 05:12:48 PDT ---
Yes, sorry I've closed some bugs which are D1-only by mistake. Apologies.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------