Skip to content

ICU-20072 Move modified = true before return to fix hasMappings() #3466

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dare3path
Copy link

This resolves a compiler warning:
collationdatabuilder.cpp:418:20: warning: code will never be executed [-Wunreachable-code].
The modified = true; line after the loop in setPrimaryRangeAndReturnNext() is unreachable due to the return within the for loop and lack of any breaks. Unlike other methods in this file (e.g., maybeSetPrimaryRange()), where modified is set before returning, this leaves modified unset despite trie updates. This could lead to hasMappings() incorrectly returning false when mappings have been added, potentially affecting downstream logic that depends on this flag. Moving modified = true; before the return primary; ensures consistency with the class’s pattern and proper state tracking.

Checklist

  • Required: Issue filed: ICU-20072
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

@markusicu markusicu self-assigned this Apr 17, 2025
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.

2 participants