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
tools/bugpoint/ToolRunner.cpp:386: bad for loop ? #31485
Comments
Hi David, Thanks for reporting this issue. Could you please verify if that fixes your issue? Thanks, |
No it doesn't. Proposed solution misses the point. For loop still has inclusive upper and lower limits, Every C programmer should know that lower limits are inclusive and Suggest have another look at my proposed solution. |
If you think that his patch is not okay, then perhaps leave comment on the code review. I posted that message on Owen's behalf since he didn't have a bugzilla account and he had to leave the office. |
I'm writing this on Owen's behalf. He requested a bugzilla login a few days ago, but it hasn't yet been created. Hi David, Thanks for looking into this revision, after looking further into the issue you describe I have found that a fix is not required. Unfortunately your suggested change will break the algorithm. The final pass in the loop is required so a remaining token can be pushed into the Args vector (line 392 to 406). As the bug regards access using the [] operator I uploaded a new revision, however I have abandoned this change due to the following in the C++11 standard: 21.4.5 basic_string element access This means that the operator[str.size()] will return '\0' Looking at your first post it appears to include an error message. Could you please describe the method used to find this? Thanks, Owen |
News to me. Thanks for the information.
I used cppcheck, a C/C++ static analyser. http://cppcheck.sourceforge.net/ I find it very useful. |
Overzealous cppcheck warning |
Extended Description
tools/bugpoint/ToolRunner.cpp:386]: (error) When Pos==CommandLine.size(), CommandLine[Pos] is out of bounds.
Source code is
for (std::size_t Pos = 0u; Pos <= CommandLine.size(); ++Pos) {
if ('\' == CommandLine[Pos]) {
Maybe better code
for (std::size_t Pos = 0u; Pos < CommandLine.size(); ++Pos) {
if ('\' == CommandLine[Pos]) {
The text was updated successfully, but these errors were encountered: