← Back to index
|
Original Bugzilla link
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
ID
Filename
Summary
Content-Type
Size
1151
bug.d
Problematic use case
application/octet-stream
709
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
Commits pushed to master at
https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/b15c4205da0d0708dde6e766d3e2ab976c7457d2
Fixes Issue 8876 - bitfields template generate wrong code
https://github.com/D-Programming-Language/phobos/commit/ce62efce7408a7780a24031048882f0e6d565674
Merge pull request #886 from Kozzi11/master Fix issue 8876