Bug 8876 – bitfields template generate wrong code

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-10-23T00:11:00Z
Last change time
2012-10-25T07:12:44Z
Assigned to
nobody
Creator
kozzi11

Attachments

IDFilenameSummaryContent-TypeSize
1151bug.dProblematic use caseapplication/octet-stream709

Comments

Comment #0 by kozzi11 — 2012-10-23T00:11:22Z
Created attachment 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)); }
Comment #1 by github-bugzilla — 2012-10-25T06:25:18Z