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

util: Replace std::basic_string<unsigned> with std::basic_string<char32_t> #8559

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

xokdvium
Copy link
Contributor

@xokdvium xokdvium commented Jan 6, 2025

Fixes build with libc++19 that fails with the error:

implicit instantiation of undefined template 'std::char_traits'

Motivation for the change: std::basic_string requires that
T implements std::char_traits and standard library provides specializations only
for the following types: char, char16_t, char32_t, wchar_t as per [1].

Note that this has been pointed out during a review previously [2], but made its
way back into the code in other places.

libc++19 has dropped implementations of std::char_traits for types not required
by the standard [3].

The base template for std::char_traits has been removed in LLVM 19.
If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t
or a custom character type for which you specialized std::char_traits, your code will stop working.

[1] N4713, 24.2.1 Character traits [char.traits] (C++17)
[2] https://www.github.com/diffblue/cbmc/pull/5277#discussion_r396609205
[3] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals


  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Discovered when building cbmc for darwin with clang-19 NixOS/nixpkgs#371275 (comment).

This change should be basically an NFC related to portability, so no tests and documentation updates seem to be necessary.

@kroening
Copy link
Member

kroening commented Jan 7, 2025

Needs clang-format, but otherwise good!

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.78%. Comparing base (5ae1452) to head (684bf42).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8559      +/-   ##
===========================================
- Coverage    78.82%   78.78%   -0.04%     
===========================================
  Files         1730     1730              
  Lines       199101   199189      +88     
  Branches     18317    18329      +12     
===========================================
- Hits        156939   156938       -1     
- Misses       42162    42251      +89     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…32_t>

Fixes build with libc++19 that fails with the error:

> implicit instantiation of undefined template 'std::char_traits<unsigned int>'

Motivation for the change: std::basic_string<T> requires that
T implements std::char_traits and standard library provides specializations only
for the following types: char, char16_t, char32_t, wchar_t as per [1].

Note that this has been pointed out during a review previously [2], but made its
way back into the code in other places.

libc++19 has dropped implementations of std::char_traits for types not required
by the standard [3].

> The base template for std::char_traits has been removed in LLVM 19.
> If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t
> or a custom character type for which you specialized std::char_traits, your code will stop working.

[1] N4713, 24.2.1 Character traits [char.traits] (C++17)
[2] https://www.github.com/diffblue/cbmc/pull/5277#discussion_r396609205
[3] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
@xokdvium xokdvium force-pushed the dev/fix-char-traits-utf32 branch from 6ba37b3 to 684bf42 Compare January 7, 2025 18:54
@xokdvium
Copy link
Contributor Author

xokdvium commented Jan 7, 2025

Thanks! Applied the clang-format diff, so the lint job should pass now.

@tautschnig tautschnig enabled auto-merge January 7, 2025 19:49
@tautschnig tautschnig merged commit 36b2335 into diffblue:develop Jan 7, 2025
36 of 38 checks passed
@xokdvium xokdvium deleted the dev/fix-char-traits-utf32 branch January 7, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants