-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Use std::declval<A>() instead of A{} to workaround gcc-12 + CWG 903 #1777
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
- it is workaround CWG 903 in gcc-12, which is considering `int{}` as null pointer constant, and so can't choose between `safe_assert_msg_types_one(uint64_t)` and `safe_assert_msg_types_one(char const *)`
- see https://godbolt.org/z/fov5xPjEe
|
Hi @alex-700! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
|
||
| template <typename... A> | ||
| safe_assert_msg_type_s<decltype(safe_assert_msg_types_one(A{}))::value...> | ||
| safe_assert_msg_type_s<decltype(safe_assert_msg_types_one(std::declval<A>()))::value...> |
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.
It looks like a shorter syntax is available.
| safe_assert_msg_type_s<decltype(safe_assert_msg_types_one(std::declval<A>()))::value...> | |
| safe_assert_msg_type_s<decltype(safe_assert_msg_types_one((A)A{}))::value...> |
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.
@yfeldblum thanks for the idea!
But I prefer to use std::declval here, because it explicitly claims that this is unevaluated context.
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.
I assumed declval might be slower to compile, but I am not seeing that assumption holding in my tests.
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.
The use of declval triggered some bug or pathological behavior somewhere. I don't know what the problem is, but that's why this was reverted.
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.
@yfeldblum should I do something with it?
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.
I have merged this again but with (A). Hopefully that will not trigger the same bug.
|
This pull request has been reverted by 7e5eefc. |
int{}as null pointer constant, and so can't choose betweensafe_assert_msg_types_one(uint64_t)andsafe_assert_msg_types_one(char const *)closes #1772