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

Undefined behavior in rfind #357

Closed
Flamefire opened this issue Oct 2, 2022 · 0 comments · Fixed by #360
Closed

Undefined behavior in rfind #357

Flamefire opened this issue Oct 2, 2022 · 0 comments · Fixed by #360

Comments

@Flamefire
Copy link
Contributor

https://github.com/boostorg/test/blob/develop/include/boost/test/utils/basic_cstring/basic_cstring.hpp#L576

This takes the address to one element before begin which is undefined behavior and recent compilers got smart enough to notice this with -Warray-bounds

Flamefire added a commit to Flamefire/test that referenced this issue Oct 10, 2022
Getting the pointer to 1-before an array is undefined behavior, i.e. `begin() - 1` is not allowed.
So modify `rfind` to loop until the front and do a final comparison with `begin()/first` afterwards before returning `npos`.
Use a better-suited for-loop and modify `find` to look as similar as possible so the difference is easy to spot.

Fixes boostorg#357
Flamefire added a commit to Flamefire/s25client that referenced this issue Apr 10, 2023
There is a Boost bug (boostorg/thread#364) in
1.69 causing a build failure with GCC 12 related to `PTHREAD_STACK_MIN`.
This is fixed in Boost 1.73 but that cannot be used yet due to an active
warning, see boostorg/test#357
Flamefire added a commit to Flamefire/s25client that referenced this issue Apr 10, 2023
There is a Boost bug (boostorg/thread#364) in
1.69 causing a build failure with GCC 12 related to `PTHREAD_STACK_MIN`.
This is fixed in Boost 1.73 but that triggers a warning in GCC12: boostorg/test#357
Hence use GCC 11 and Boost 1.73
Flamefire added a commit to Flamefire/s25client that referenced this issue Apr 10, 2023
There is a Boost bug (boostorg/thread#364) in
1.69 causing a build failure with GCC 12 related to `PTHREAD_STACK_MIN`.
This is fixed in Boost 1.73 but that triggers a warning in GCC12: boostorg/test#357
Hence use GCC 11 and Boost 1.73
Flamefire added a commit to Flamefire/s25client that referenced this issue Apr 10, 2023
There is a Boost bug (boostorg/thread#364) in
1.69 causing a build failure with GCC 12 related to `PTHREAD_STACK_MIN`.
This is fixed in Boost 1.73 but that triggers a warning in GCC12: boostorg/test#357
Hence use GCC 11 and Boost 1.73
Flamefire added a commit to Flamefire/s25client that referenced this issue Apr 12, 2023
There is a Boost bug (boostorg/thread#364) in
1.69 causing a build failure with GCC 12 related to `PTHREAD_STACK_MIN`.
This is fixed in Boost 1.73 but that triggers a warning in GCC12: boostorg/test#357
Hence use GCC 11 and Boost 1.73
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 a pull request may close this issue.

1 participant