add more constexpr to utf8_to_utf16.h#943
Conversation
|
Thanks, but I think this needs to use the simdutf_constexpr macro since this requires C++17. |
|
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? |
|
@pauldreik Let us wait a day and if it does not work, I will act. |
|
@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? |
|
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). |
|
@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.
It seems like it did not start working, despite being a new month :( |
|
@pauldreik My credit card expired. I had updated my credit card number on my personal account but not here. It should work now. |
|
@pauldreik Green. The power of a credit card! |
|
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! |
Short title (summary):
Fix: Suppress
-Warray-boundswarning usingif constexprDescription
What did you change and why?
Updated the branching logic to use
if constexprso the condition is evaluated at compile time. This explicitly tells the compiler which branch is dead code, preventing it from emitting a-Warray-boundswarning 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-boundsenabled). 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)