-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
JDK-8312395: Improve assertions in growableArray #14946
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval in principle but I have a suggestion.
Thanks
@@ -142,17 +142,17 @@ class GrowableArrayView : public GrowableArrayBase { | |||
} | |||
|
|||
E& at(int i) { | |||
assert(0 <= i && i < _len, "illegal index"); | |||
assert(0 <= i && i < _len, "illegal index %d, %d accessible elements", i, _len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
"Illegal index %d for length %d"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good suggestions !
I adjusted the output following your suggestion and also added some output to a few more asserts. Btw any idea why so much 'this->_len' syntax is used at some places and not just _len or other field names ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@MBaesken This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 4 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
looks
Probably some IDE-code-completion-related artifacts. E.g. typing "this->" in CDT gives me all members, and maybe someone just hit Enter then and took the full completion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One further suggestion but approving anyway.
I think the use of this->xxx
is just personal style. I find it unnecessary especially given the other uses in this file.
Thanks.
assert(0 <= start, "illegal index"); | ||
assert(start < end && end <= _len, "erase called with invalid range"); | ||
assert(0 <= start, "illegal start index %d", start); | ||
assert(start < end && end <= _len, "erase called with invalid range %d, %d", start, end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'd want to see _len
here too - suggestion:
"erase called with invalid range (%d, %d) for length %d", start, end, _len
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi David, I agree !
Interestingly enough I get compiler errors when leaving out "this->" (GCC 10.3). It may be because the member is part of a templatized base class. Odd, though.
|
Hi David and Thomas, thanks for the reviews ! /integrate |
Going to push as commit b772e67.
Your commit was automatically rebased without conflicts. |
Qualification with |
Thanks @kimbarrett ! |
There are a number of assertions in growableArray , for example to check for a valid index to access/remove elements.
Those assertions can be improved, e.g. by showing the bad index value used in case of failure.
Example for an assertion in the 'at(index i)' access method
old assertion looks like
assert(0 <= i && i < _len) failed: illegal index
new assertion looks like
assert(0 <= i && i < _len) failed: illegal index -559030609, 1 accessible elements
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14946/head:pull/14946
$ git checkout pull/14946
Update a local copy of the PR:
$ git checkout pull/14946
$ git pull https://git.openjdk.org/jdk.git pull/14946/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14946
View PR using the GUI difftool:
$ git pr show -t 14946
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14946.diff
Webrev
Link to Webrev Comment