www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: guido 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)));
}


-- 
Mar 27 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1082


bugzilla digitalmars.com changed:

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





Fixed dmd 1.011


-- 
Apr 11 2007