Bug 1082 – The .offsetof property yields a signed int, a size_t would be more appropriate
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2007-03-27T19:57:00Z
Last change time
2014-02-16T15:23:42Z
Assigned to
bugzilla
Creator
guido
Comments
Comment #0 by guido — 2007-03-27T19:57:37Z
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)));
}