1082 – The .offsetof property yields a signed int, a size_t would be more appropriate

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1082 - The .offsetof property yields a signed int, a size_t would be more appropriate
Summary: The .offsetof property yields a signed int, a size_t would be more appropriate
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
Reported: 2007年03月27日 19:57 UTC by Mark Guidarelli
Modified: 2014年02月16日 15:23 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Mark Guidarelli 2007年03月27日 19:57:37 UTC
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)));
}
Comment 1 Walter Bright 2007年04月11日 22:02:00 UTC
Fixed dmd 1.011


AltStyle によって変換されたページ (->オリジナル) /