Summary: strtol() is improperly declared
           Product: D
           Version: 1.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]

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:
Error: AssertError Failure a(5)


Reply via email to