Fix error_category
regression with Boost.System
#3176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followup to #3139.
Bad kitties jump up on the table where they're not allowed. 😼 Boost.System was a very bad kitty:
https://github.com/boostorg/system/blob/9a6d79b84147854aa919644b56b8553f5a2bedb8/include/boost/system/detail/std_category.hpp#L46-L52
When #3139 fixed
error_category
's default constructor to beconstexpr
, it had to change_Addr
into aunion
, breaking this highly non-Standard code in Boost.System. This resulted in widespread breakage in our test team's "Real World Code" suites.Because Boost is a widely used third-party library, even if we reported this upstream and they were somehow able to avoid doing this, or simply changed their non-Standard code to detect our new
error_category
and use different non-Standard code, projects throughout the C++ ecosystem would be broken until they updated Boost.Adjusting the STL's code to continue permitting this non-Standard usage is the least undesirable option here (compared to reverting #3139, refusing to yield, adding an escape hatch, etc.). Notes for these changes:
public
operator=
to_Addr_storage
, but it and_Addr
are stillprotected
, so this is not observable to Standard code.constexpr
to be "transparent", even though Boost doesn't need this.uintptr_t
also to be transparent, because that's what we store.noexcept
to avoid emitting EH enforcement.While RWC test coverage would be sufficient, I'm adding a bit of test code in order to more quickly detect any maintenance changes that would break this workaround. The test takes
unsigned int
because that's what Boost is using.(To be clear, I love Boost and I've used it for 20 years, but accessing internal data members is problematic for precisely this reason! 😹)