This is an archive of the discontinued LLVM Phabricator instance.

[libc++][ABI Break] Make is_error_condition_enum_v and is_error_code_enum_v bool, not size_t
ClosedPublic

Authored by jloser on Oct 26 2021, 9:07 AM.

Details

Summary

is_error_condition_enum_v and is_error_code_enum_v are currently of
type size_t, but the standard mandates they are of type bool.

This is an ABI break technically since the size of these variable
templates has changed. Document it as such in the release notes.

Fixes https://bugs.llvm.org/show_bug.cgi?id=50755

Diff Detail

Event Timeline

jloser requested review of this revision.Oct 26 2021, 9:07 AM
jloser created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2021, 9:07 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Arguably this should add a regression test. Certainly seems straightforward enough, though, right?
As usual I'm a little unsure of what the ABI implications are (notice is_error_code_enum_v is not _LIBCPP_HIDE_FROM_ABI), but this is also clearly a bugfix and I assume we'd bite the bullet if there were one.

jloser updated this revision to Diff 382378.Oct 26 2021, 9:52 AM

Add tests to verify the variable templates are of the right type

jloser added a comment.EditedOct 26 2021, 9:55 AM

Arguably this should add a regression test. Certainly seems straightforward enough, though, right?
As usual I'm a little unsure of what the ABI implications are (notice is_error_code_enum_v is not _LIBCPP_HIDE_FROM_ABI), but this is also clearly a bugfix and I assume we'd bite the bullet if there were one.

I was on the fence given how "trivially obvious" the change is, but looks like we did get it wrong at one point...so, I added a simple test for both variable templates.

I agree regarding the ABI break this technically is, but, like you said, it's a bugfix, so it is what it is. I recall in one of my recent PRs we talked about symbol visibility wrt variable templates, but don't think any of us have an immediate planned follow-up. Louis and I have talked offline briefly about some ideas of testing for symbol visibility before we go change the library as a whole in one sweeping fashion.

@ldionne - should we make these variable templates as _LIBCPP_HIDE_FROM_ABI while we're here?

Changing the size of the object sounds like an ABI break to me. So I'd like @ldionne to decide whether this change requires an ABI version guard or not. Other then that the change LGTM.

var-const accepted this revision.Oct 26 2021, 12:35 PM

LGTM (once the ABI discussion is resolved).

ldionne accepted this revision.Oct 28 2021, 12:00 PM

It is technically an ABI break, but I literally can't imagine someone being bitten by it -- perhaps I'm not imaginative enough? One would have to basically have a data member or function parameter of type decltype(is_error_condition_enum_v<...>), or something along those lines. Given the name of the utility, which starts with is_, everybody has probably been using it correctly, i.e. as a compile-time boolean and nothing else. IMO not fixing that bug based on ABI break concerns would be unreasonable. I'll take the responsibility for it if things turn sour :-). Let's add a release note and call it a day.

Regarding adding visibility/linkage annotations to those variable templates -- I wouldn't do it, I think we'll want to find a solution to treat all the variable templates consistently.

This revision is now accepted and ready to land.Oct 28 2021, 12:00 PM
jloser updated this revision to Diff 383119.Oct 28 2021, 12:24 PM
jloser retitled this revision from [libc++] Make is_error_condition_enum_v and is_error_code_enum_v bool, not size_t to [libc++][ABI Break] Make is_error_condition_enum_v and is_error_code_enum_v bool, not size_t.
jloser edited the summary of this revision. (Show Details)

Add release note detailing the ABI break

ldionne accepted this revision.Oct 28 2021, 12:27 PM

Ship it! Our CI is unstable right now. Given the nature and triviality of this change, I think it's reasonable to ship this if your tests pass locally.

This revision was landed with ongoing or failed builds.Oct 28 2021, 12:40 PM
This revision was automatically updated to reflect the committed changes.