Repository navigation
Conversation
…achable branch arrayIndex() checked the indexes of every branch, also of a discarded if constexpr branch and of a branch whose condition is known once the template is instantiated. Skip the unreachable branches with skipUnreachableBranch(), as the other checks that walk all tokens do.
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.
arrayIndex()reports indexes in branches that can never be taken: a discardedif constexprbranch (#14992), and a branch whose condition is known once the template is instantiated (#14989). Both are errors, so they show up in a default run:The token loop of
arrayIndex()(checkbufferoverrun.cpp#L301-L306) now starts withskipUnreachableBranch(), like the loops in checktype.cpp, checkother.cpp, checkfunctions.cpp and checkexceptionsafety.cpp. The full example of #14989 no longer gives its six errors. An out-of-bounds index in anif constexprbranch that is taken is still reported, which the test checks too. As with the other checks, an index in a block such asif (false)is no longer reported either.I don't have a Trac account, so I can't assign the tickets to myself.