[Issue 2467] New: strtol() is improperly declared
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Nov 22 03:04:11 PST 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 at digitalmars.com
        ReportedBy: davidell at 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)
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list