On Thu, Oct 06, 2022 at 12:39:40PM -0700, Linus Torvalds wrote: > What confuses me is that error message ("array subscript [0, 0] is > outside array bounds of 'struct dc_writeback_info[1]') which seems to > be aware that the value is actually 0. I've seen bugs in the tracker where the reporting is broken but the range checker is working "correctly", which seems to be the case here. > If somebody cannot come up with a fix, I suspect the solution is "gcc > array bounds analysis is terminally buggy" and we just need to disable > it for gcc-11 too. It does continue to find bugs, so I'd rather keep it on. GCC has fixed all the issues we've run into so far (though not all have been back ported to GCC 12 yet, so yes, let's keep -Warray-bounds disabled there). Specifically, I've been tracking: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105679 Fixed 13+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 Fixed 12+, 11.3 And it looks like Sudip's proposed fix for this particular code is additionally fixing unsigned vs signed as well. I think -Warray-bounds did its job (though, with quite a confusing index range in the report). -Kees -- Kees Cook