-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Suppress warnings with latest Apple clang/libc++. #4486
Conversation
There is a bad interaction between our empty_base_optimization and libc++'s obsolete implementation of std::equal_to. This involves the deprecated functions std::binary_function and std::unary_function. This commit suppresses the warnings for the use of these functions on libc++, but has to call libc++-specific api (on libc++ only).
@@ -189,15 +187,13 @@ class aged_ordered_container | |||
: public beast::detail::empty_base_optimization<Compare> | |||
#ifdef _LIBCPP_VERSION | |||
, | |||
public std::binary_function<Key, element, bool> |
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.
what would adding the double underscore do?
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.
This takes advantage of a libc++-only feature. std::binary_function
is marked deprecated. But as an implementation technique of libc++, std::__binary_function
has the same functionality as std::binary_function
but is not marked deprecated. This is done as a hack in libc++ to avoid rewriting things that used to depend on std::binary_function
but no longer do. And that hack is reused here in rippled.
If the hack goes away (libc++ comes into conformance), then we will get a compile-time error, and all we'll have to do is remove the code within #ifdef _LIBCPP_VERSION
.
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.
thanks!
Fails to build on OSX M1, Ventura 13.3.1, apple clang 14.0.0, conan 1.59.0, cmake 3.23.2:
|
Include a transition from pre-hack to post-hack.
Thanks for the detailed report @gregtatcam ! I didn't realize I needed a transition story across different versions of libc++. I've added this as a commit-to-be-merged. If you could rerun your test with this update I would be most grateful. I no longer have the version of libc++ you do, so I'm unable to test against it. |
Sure, no problem. Getting these errors after the update:
|
Thanks @gregtatcam. I actually changed that file but neglected to hit save! |
It builds now! |
Closing because @thejohnfreeman has a superior solution. |
Address issues related to the removal of `std::{u,bi}nary_function` in C++17 and some warnings with Clang 16. Some warnings appeared with the upgrade to Apple clang version 14.0.3 (clang-1403.0.22.14.1). - `std::{u,bi}nary_function` were removed in C++17. They were empty classes with a few associated types. We already have conditional code to define the types. Just make it unconditional. - libc++ checks a cast in an unevaluated context to see if a type inherits from a binary function class in the standard library, e.g. `std::equal_to`, and this causes an error when the type privately inherits from such a class. Change these instances to public inheritance. - We don't need a middle-man for the empty base optimization. Prefer to inherit directly from an empty class than from `beast::detail::empty_base_optimization`. - Clang warns when all the uses of a variable are removed by conditional compilation of assertions. Add a `[[maybe_unused]]` annotation to suppress it. - As a drive-by clean-up, remove commented code. See related work in #4486.
There is a bad interaction between our empty_base_optimization and libc++'s obsolete implementation of std::equal_to. This involves the deprecated functions std::binary_function and std::unary_function.
This commit suppresses the warnings for the use of these functions on libc++, but has to call libc++-specific api (on libc++ only). This commit has no impact on platforms that do not use libc++.
These warnings do not appear until the upgrade to Apple clang version 14.0.3 (clang-1403.0.22.14.1).
High Level Overview of Change
Context of Change
Type of Change