Skip to content

Fix 14956: FP arrayIndexOutOfBounds with break in loop - #8772

Open
pfultz2 wants to merge 3 commits into
cppcheck-opensource:mainfrom
pfultz2:valueflow-skip-unconditional-break
Open

Fix 14956: FP arrayIndexOutOfBounds with break in loop#8772
pfultz2 wants to merge 3 commits into
cppcheck-opensource:mainfrom
pfultz2:valueflow-skip-unconditional-break

Conversation

@pfultz2

@pfultz2 pfultz2 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

" arr[idx] = 0;\n"
"}\n");
ASSERT_EQUALS(
"[test.cpp:9:8]: (error) Array 'arr[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I am new so sorry if this is a silly question.

I thought that if we want to return an error, we must be guaranteed that it is actually an error. In this input it looks like the array access is only out of bounds if c is true. Since we don't know anything about c, I thought we couldn't report any errors. I would expect the correct output for this testcase to be no errors.

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