[Issue 1082] New: The .offsetof property yields a signed int, a size_t would be more appropriate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 27 17:57:52 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1082

           Summary: The .offsetof property yields a signed int, a size_t
                    would be more appropriate
           Product: D
           Version: 1.010
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: guido at grumpy-cat.com


The .offsetof property yields a signed int value, an unsigned int like size_t
would be more appropriate.  Also the exact type yielded by .offsetof should be
documented in the Portability Guide of the documentation.  The types yielded by
.length, .sizeof, and .alignof are specified there. 


/*
        dmd -w -O test.d
        ./test
        size_t type = uint
        sizeof type = uint
        alignof type = uint
        offsetof type = int
*/
import std.stdio;

struct foo {
        int bar;
}

void main() {
        writefln("size_t type = ", typeid(size_t));
        writefln("sizeof type = ", typeid(typeof(foo.bar.sizeof)));
        writefln("alignof type = ", typeid(typeof(foo.bar.alignof)));
        writefln("offsetof type = ", typeid(typeof(foo.bar.offsetof)));
}


-- 



More information about the Digitalmars-d-bugs mailing list