[Issue 8876] New: bitfields template generate wrong code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 23 00:11:24 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8876
Summary: bitfields template generate wrong code
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: kozzi11 at gmail.com
--- Comment #0 from Daniel Kozak <kozzi11 at gmail.com> 2012-10-23 00:11:22 PDT ---
Created an attachment (id=1151)
Problematic use case
mixin(bitfields!(
uint, "machine", 24,
ushort, "pid", 16,
uint, "inc", 24
));
generate for machine field this code:
@property @safe void machine(uint v) pure nothrow {
assert(v >= machine_min);
assert(v <= machine_max);
_machine_pid_inc = cast(typeof(_machine_pid_inc)) ((_machine_pid_inc &
~16777215U) | ((cast(typeof(_machine_pid_inc)) v << 0U) & 16777215U));
}
but this is wrong because _machine_pid_inc & ~16777215U clear some other bits;
it should generate code like this:
@property @safe void machine(uint v) pure nothrow {
assert(v >= machine_min);
assert(v <= machine_max);
_machine_pid_inc = cast(typeof(_machine_pid_inc)) ((_machine_pid_inc &
~16777215UL) | ((cast(typeof(_machine_pid_inc)) v << 0U) & 16777215U));
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list