Skip to content

Replace bitwise assignment ops on bools#2279

Merged
jacobhinkle merged 1 commit intomainfrom
remove_bool_bitwise_assignment
May 22, 2024
Merged

Replace bitwise assignment ops on bools#2279
jacobhinkle merged 1 commit intomainfrom
remove_bool_bitwise_assignment

Conversation

@jacobhinkle
Copy link
Collaborator

Thanks to the suggestion by @zasdfgbnm while reviewing #2272, I found some additional cases where we took a short-cut to updating bools using the bitwise assignment ops. This is not ideal since its behavior is undefined (there's no guarantee that the underlying representation of true is b1 and not b10 or any other non-zero value). More importantly, writing a |= b as a = a || b allows us to short-circuit if a == true. Using bitwise a |= b, b will always be evaluated.

@jacobhinkle jacobhinkle requested a review from zasdfgbnm May 21, 2024 23:49
@jacobhinkle
Copy link
Collaborator Author

!build

@jacobhinkle jacobhinkle merged commit 46625f9 into main May 22, 2024
@jacobhinkle jacobhinkle deleted the remove_bool_bitwise_assignment branch May 22, 2024 11:37
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.

2 participants