Skip to content

add more constexpr to utf8_to_utf16.h#943

Merged
pauldreik merged 2 commits intosimdutf:masterfrom
spkapust:patch-1
Mar 5, 2026
Merged

add more constexpr to utf8_to_utf16.h#943
pauldreik merged 2 commits intosimdutf:masterfrom
spkapust:patch-1

Conversation

@spkapust
Copy link
Copy Markdown
Contributor

@spkapust spkapust commented Feb 26, 2026

Short title (summary):
Fix: Suppress -Warray-bounds warning using if constexpr

Description
What did you change and why?
Updated the branching logic to use if constexpr so the condition is evaluated at compile time. This explicitly tells the compiler which branch is dead code, preventing it from emitting a -Warray-bounds warning for out-of-bounds array accesses that will never actually execute at runtime.

Issue reproduced / related issue:
N/A

Type of change
[x] Bug fix
[ ] Optimization
[ ] New feature
[ ] Refactor / cleanup
[ ] Documentation / tests
[ ] Other (please describe):

How to verify / test
Compile the project using a compiler and flags that previously generated the warning (e.g., GCC or Clang with -Warray-bounds enabled). Verify that the warning is no longer emitted during the build process. Run the standard test suite (e.g., ctest --test-dir build) to ensure the runtime logic remains correct and no regressions were introduced.

Checklist before submitting
[ ] I added/updated tests covering my change (if applicable) (Note: Likely N/A for a compiler warning fix)
[x] Code builds locally and passes my check
[ ] Documentation / README updated if needed
[x] Commits are atomic and messages are clear
[ ] I linked the related issue (if applicable)

@pauldreik
Copy link
Copy Markdown
Collaborator

Thanks, but I think this needs to use the simdutf_constexpr macro since this requires C++17.

@pauldreik
Copy link
Copy Markdown
Collaborator

we have run out of budget on CI, that is why the actions all fail. maybe it resets tomorrow, when there is a new month?
ping @lemire

@lemire
Copy link
Copy Markdown
Member

lemire commented Feb 28, 2026

@pauldreik Let us wait a day and if it does not work, I will act.

@pauldreik
Copy link
Copy Markdown
Collaborator

@spkapust when you have done the suggested change, can you please rebase on main and then we can try running the CI again?

also, what compiler and OS did you use to see the warning?

@spkapust
Copy link
Copy Markdown
Contributor Author

spkapust commented Mar 2, 2026

Thanks @pauldreik! I'll make the switch to the simdutf_constexpr macro and get this rebased on main at some point this week.

To answer your question in the meantime: We ran into this warning/error while building on gLinux, and the compiler was GCC (fairly certain v15.2).

@lemire
Copy link
Copy Markdown
Member

lemire commented Mar 2, 2026

@spkapust Please push an update.

Uses `simdutf_constexpr if` to let the compiler know which branch will never be executed to avoid emitting of the `-Warray-bounds` warning on code paths that would do an out of bounds array access.
@pauldreik
Copy link
Copy Markdown
Collaborator

@pauldreik Let us wait a day and if it does not work, I will act.

It seems like it did not start working, despite being a new month :(

@lemire
Copy link
Copy Markdown
Member

lemire commented Mar 3, 2026

@pauldreik My credit card expired. I had updated my credit card number on my personal account but not here.

It should work now.

@lemire
Copy link
Copy Markdown
Member

lemire commented Mar 3, 2026

@pauldreik Green.

The power of a credit card!

@pauldreik pauldreik changed the title Update utf8_to_utf16.h add more constexpr to utf8_to_utf16.h Mar 5, 2026
@pauldreik pauldreik merged commit a14c6ad into simdutf:master Mar 5, 2026
84 checks passed
@pauldreik
Copy link
Copy Markdown
Collaborator

I changed the title to be more descriptive. I also looked in the ci job which uses clang-21 and gcc 15 for warnings but could not see any. This PR is good regardless. Thanks!

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