Skip to content

[Issue 15305] bitfields! setter erroneously clears subsequent fields #3815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2015

Conversation

lionello
Copy link
Contributor

@property void alice(bool v) @safe pure nothrow @nogc { if (v) _alice_bob |= 1U;else _alice_bob &= ~1U;}

This getter is wrong because the &=~1U would clear not just the first bit, but bits 32-64 as well. This in turn because of the code in myToString, which picks the smallest type suffix, U in this case.

Fixed by casting the 1U to the type of the storage, before negating.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
15305 std.manip.bitfields generate bogous code

@andralex
Copy link
Member

Thanks!

andralex added a commit that referenced this pull request Nov 16, 2015
[Issue 15305] bitfields! setter erroneously clears subsequent fields
@andralex andralex merged commit 4e53643 into dlang:master Nov 16, 2015
@lionello lionello deleted the issue15305 branch November 16, 2015 14:19
@dnadlinger
Copy link
Member

@lionello: If you include "fix" in the commit subject, the issue will get closed on Bugzilla automatically (and the dlang-bot report will have a check mark instead of an X).

@lionello
Copy link
Contributor Author

@klickverbot Cool, I did not know that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants