-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Utilize std::make_unsigned_t instead of wrapping lshift #35323
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
Conversation
Currently lshift_kernel uses a hacky wrapper that wraps all integer types. This is unnecessary because we have std::make_unsigned_t [ghstack-poisoned]
💊 CircleCI build failures summary and remediationsAs of commit dc94be3 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no CircleCI failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 8 times. |
Currently lshift_kernel uses a hacky wrapper that wraps all integer types. This is unnecessary because we have std::make_unsigned_t [ghstack-poisoned]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
| } | ||
|
|
||
| static inline int64_t lshift_wrapper(int64_t a, int64_t b) { | ||
| return ((uint64_t)a) << b; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why do we have to make the left hand side unsigned before performing the shift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably because shifting on signed integers in C++ is implementation defined. See https://stackoverflow.com/a/4009954/1150462 for an explanation and reference.
Currently lshift_kernel uses a hacky wrapper that wraps all integer types. This is unnecessary because we have std::make_unsigned_t [ghstack-poisoned]
|
Weird, this has actually been merged in beac3f2 . Manually closing now. |
Stack from ghstack:
Currently lshift_kernel uses a hacky wrapper that wraps all integer
types. This is unnecessary because we have std::make_unsigned_t
Differential Revision: D20824641