Skip to content
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

Fix uses of __cpp_lib_constexpr_string #18890

Conversation

keith
Copy link
Contributor

@keith keith commented Oct 17, 2024

The intent of these checks was that if the C++20 version of this feature
are enabled to execute the top codepath. libstdc++ 12 defines this
feature as:

// in: /usr/include/c++/12/bits/basic_string.h

#ifdef __cpp_lib_is_constant_evaluated
// Support P0980R1 in C++20.
# define __cpp_lib_constexpr_string 201907L
#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
// Support P0426R1 changes to char_traits in C++17.
# define __cpp_lib_constexpr_string 201611L
#endif

So this codepath was always being hit even with -std=c++17 and then
resulted in a failure because the string wasn't actually constinit. This
matches the other use of this feature check in inlined_string_field.h

@keith keith requested a review from a team as a code owner October 17, 2024 21:25
@keith keith requested review from sbenzaquen and removed request for a team October 17, 2024 21:25
@zhangskz zhangskz added c++ 🅰️ safe for tests Mark a commit as safe to run presubmits over labels Oct 17, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Oct 17, 2024
@zhangskz zhangskz requested review from haberman and removed request for haberman October 18, 2024 16:35
@zhangskz
Copy link
Member

Looks like there's a conflict -- can you rebase / resolve? upb / No System Python test also seems to be failing (incl. rerun) but seems unrelated afaict. @haberman thoughts?

@keith
Copy link
Contributor Author

keith commented Oct 18, 2024

looks like the commit that introduced this was rolled back f58849b

maybe a googler can comment on if that's going to come back out, or if this patch is irrelevant

@tonyliaoss
Copy link
Member

Change bd03560 got rolled back in f58849b due to some Google internal code relying on UB and breaking as a result :) It's definitely something we want to eventually ship out again once we fix all the internal breakages.

@shaod2 shaod2 requested a review from tonyliaoss October 21, 2024 20:23
@sbenzaquen
Copy link
Contributor

The change was submitted again.

The intent of these checks was that if the C++20 version of this feature
are enabled to execute the top codepath. libstdc++ 12 defines this
feature as:

```cpp
// in: /usr/include/c++/12/bits/basic_string.h

#ifdef __cpp_lib_is_constant_evaluated
// Support P0980R1 in C++20.
# define __cpp_lib_constexpr_string 201907L
#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
// Support P0426R1 changes to char_traits in C++17.
# define __cpp_lib_constexpr_string 201611L
#endif
```

So this codepath was always being hit even with -std=c++17 and then
resulted in a failure because the string wasn't actually constinit. This
matches the other use of this feature check in `inlined_string_field.h`
@keith keith force-pushed the ks/fix-uses-of-__cpp_lib_constexpr_string branch from 91bb279 to edb4f5f Compare November 13, 2024 19:12
@keith
Copy link
Contributor Author

keith commented Nov 13, 2024

reabsed!

Copy link
Member

@tonyliaoss tonyliaoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for tests

@tonyliaoss tonyliaoss added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Nov 13, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Nov 13, 2024
copybara-service bot pushed a commit that referenced this pull request Nov 14, 2024
The intent of these checks was that if the C++20 version of this feature
are enabled to execute the top codepath. libstdc++ 12 defines this
feature as:

```cpp
// in: /usr/include/c++/12/bits/basic_string.h

#ifdef __cpp_lib_is_constant_evaluated
// Support P0980R1 in C++20.
# define __cpp_lib_constexpr_string 201907L
#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
// Support P0426R1 changes to char_traits in C++17.
# define __cpp_lib_constexpr_string 201611L
#endif
```

So this codepath was always being hit even with -std=c++17 and then
resulted in a failure because the string wasn't actually constinit. This
matches the other use of this feature check in `inlined_string_field.h`

Closes #18890

COPYBARA_INTEGRATE_REVIEW=#18890 from keith:ks/fix-uses-of-__cpp_lib_constexpr_string edb4f5f
FUTURE_COPYBARA_INTEGRATE_REVIEW=#18890 from keith:ks/fix-uses-of-__cpp_lib_constexpr_string edb4f5f
PiperOrigin-RevId: 696299666
copybara-service bot pushed a commit that referenced this pull request Nov 14, 2024
The intent of these checks was that if the C++20 version of this feature
are enabled to execute the top codepath. libstdc++ 12 defines this
feature as:

```cpp
// in: /usr/include/c++/12/bits/basic_string.h

#ifdef __cpp_lib_is_constant_evaluated
// Support P0980R1 in C++20.
# define __cpp_lib_constexpr_string 201907L
#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
// Support P0426R1 changes to char_traits in C++17.
# define __cpp_lib_constexpr_string 201611L
#endif
```

So this codepath was always being hit even with -std=c++17 and then
resulted in a failure because the string wasn't actually constinit. This
matches the other use of this feature check in `inlined_string_field.h`

Closes #18890

COPYBARA_INTEGRATE_REVIEW=#18890 from keith:ks/fix-uses-of-__cpp_lib_constexpr_string edb4f5f
FUTURE_COPYBARA_INTEGRATE_REVIEW=#18890 from keith:ks/fix-uses-of-__cpp_lib_constexpr_string edb4f5f
PiperOrigin-RevId: 696299666
protobuf-team-bot added a commit that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants