https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109437
Bug ID: 109437
Summary: -Wanalyzer-out-of-bounds is emitted at most once per
frame.
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: priour.be at gmail dot com
CC: priour.be at gmail dot com
Target Milestone: ---
Build: 13.0.1 20230328 (experimental)
OOB refers to Out-Of-Bounds.
Curiously, it seems that if a frame was a cause for a OOB (either by containing
the spurious code or by being a caller to such code), it will only emit one set
of warning, rather than at each unique compromising statements.
int consecutive_oob_in_frame ()
{
int arr[] = {1,2,3,4,5,6,7};
int y1 = arr[9]; // only this one is diagnosed
int y2 = arr[10]; // no OOB warning emitted here ...
int y3 = arr[50]; // ... nor here.
return (y1+y2+y3);
}
int main () {
consecutive_oob_in_frame (); // OOB warning emitted
int x [] = {1,2};
x[5]; /* silent, probably because another set of OOB warnings
has already been issued with this frame being the source */
return 0;
}
As per David suggestion, it might be worth to implement
pending_diagnostic::supercedes_p vfunc for the OOB checker.