Open
Conversation
* utf8casecmp is calling utf8codepoint which is non-pure * utf8chr is calling utf8str which calls utf8codepoint * utf8ncasecmp is calling utf8codepoint * utf8str calls utf8codepoint * utf8casestr calls utf8codepoint
sheredom
reviewed
Sep 9, 2023
| /* Return less than 0, 0, greater than 0 if src1 < src2, src1 == src2, src1 > | ||
| * src2 respectively, case insensitive. */ | ||
| utf8_constexpr14 utf8_nonnull utf8_pure int | ||
| utf8_constexpr14 utf8_nonnull int |
Owner
There was a problem hiding this comment.
Sorry colour me dumb here - why is this not pure?
Author
There was a problem hiding this comment.
Because it's calling utf8codepoint which is a non-pure function (utf8codepoint is writing to the pointer it receives as a parameter). This results in undefined behavior which is not very well handled by clang.
Owner
There was a problem hiding this comment.
Oh that's annoying. I might just change that instead!
Author
There was a problem hiding this comment.
You mean the definition of utf8codepoint? I think that would require something like:
utf8_constexpr14_impl struct { utf8_int8_t *str; utf8_int32_t out_codepoint; }
utf8codepoint(const utf8_int8_t *utf8_restrict str)
so that the function becomes pure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This drops utf8_pure where the functions do non-pure calls and adds utf8_pure to functions that are not already marked pure.