Skip to content

src: restrict MaybeStackBuffer string helpers to text types#62564

Closed
anonrig wants to merge 1 commit intonodejs:mainfrom
anonrig:yagiz/fix-macos-warning
Closed

src: restrict MaybeStackBuffer string helpers to text types#62564
anonrig wants to merge 1 commit intonodejs:mainfrom
anonrig:yagiz/fix-macos-warning

Conversation

@anonrig
Copy link
Copy Markdown
Member

@anonrig anonrig commented Apr 2, 2026

Limit MaybeStackBuffer::ToString() and ToStringView to textual element types so byte buffers do not instantiate std::basic_string[_view] on libc++.

This avoids the macOS/Xcode deprecation warning for char_traits<unsigned char> while preserving existing string helper behavior for text buffers. uint16_t buffers are mapped to char16_t for these conversions so UTF-16 call sites continue to work.

@anonrig anonrig requested a review from addaleax April 2, 2026 16:39
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 2, 2026

template <typename T>
using MaybeStackBufferStringType =
std::conditional_t<std::is_same_v<T, uint16_t>, char16_t, T>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should just be a concept

   template <typename T>
  concept MaybeStackBufferStringLike =
      std::is_same_v<T, char> || std::is_same_v<T, wchar_t> ||
      std::is_same_v<T, char8_t> || std::is_same_v<T, char16_t> ||
      std::is_same_v<T, char32_t> || std::is_same_v<T, uint16_t>;

// ...

template <MaybeStackBufferStringLike U = T,
        typename Char = MaybeStackBufferStringType<U>>

@targos
Copy link
Copy Markdown
Member

targos commented Apr 2, 2026

Issue: #62506

There's a PR from a first time contributor at #62507

@anonrig
Copy link
Copy Markdown
Member Author

anonrig commented Apr 2, 2026

Issue: #62506

There's a PR from a first time contributor at #62507

I'll close. Let's get a new contributor!

@anonrig anonrig closed this Apr 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (a9ac9b1) to head (69be72f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #62564   +/-   ##
=======================================
  Coverage   89.70%   89.70%           
=======================================
  Files         695      695           
  Lines      214213   214214    +1     
  Branches    41021    41024    +3     
=======================================
+ Hits       192167   192169    +2     
+ Misses      14113    14109    -4     
- Partials     7933     7936    +3     
Files with missing lines Coverage Δ
src/util.h 90.98% <100.00%> (+0.07%) ⬆️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants