https://gcc.gnu.org/g:8b4ed6bbfb9fd4029a78265088e24b7500f33037
commit r17-906-g8b4ed6bbfb9fd4029a78265088e24b7500f33037 Author: Jonathan Wakely <[email protected]> Date: Wed May 20 22:24:33 2026 +0100 cobol: Add assertion to suppress -Warray-bounds false positive [PR125404] This works around a warning from std::vector code, which seems to be assuming that the vector is empty and therefore calling back() would be invalid: /home/test/src/gcc/gcc/cobol/symfind.cc:526:45: error: array subscript -1 is outside array bounds of ‘long unsigned int [1152921504606846975]’ [-Werror=array-bounds=] 526 | return ancestors.back() == i01; | ~~~~~~~~~~~~~~~~~^~~~~~ Compiling with -D_GLIBCXX_ASSERTIONS also fixes the warning. gcc/cobol/ChangeLog: PR cobol/125404 * symfind.cc (symbol_find): Add assertion that ancestors vector is not empty. Diff: --- gcc/cobol/symfind.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc index cefc560bf31b..84eb0166cf64 100644 --- a/gcc/cobol/symfind.cc +++ b/gcc/cobol/symfind.cc @@ -523,6 +523,7 @@ symbol_find( size_t program, std::list<const char *> names ) { std::inserter(qualified, qualified.begin()), [i01]( auto item ) { const std::vector<size_t>& ancestors(item.second); + assert(!ancestors.empty()); return ancestors.back() == i01; } ); items = qualified;
