From: Jonathan Wakely Date: Tue, 18 Mar 2025 18:37:01 +0000 (+0000) Subject: cobol: Fix incorrect use of std::remove_if X-Git-Tag: basepoints/gcc-16~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6621e5a1d1195137a1dd6d917961ab23609a244c;p=thirdparty%2Fgcc.git cobol: Fix incorrect use of std::remove_if The call to std::remove_if used here doesn't remove any elements, it just overwrites the "removed" elements with later elements, leaving the total number of elements unchanged. Use std::list::remove_if to actually remove those unwanted elements from the list. gcc/cobol/ChangeLog: * symfind.cc (finalize_symbol_map2): Use std::list::remove_if instead of std::remove_if. --- diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc index 2687fdb83df..899571551e8 100644 --- a/gcc/cobol/symfind.cc +++ b/gcc/cobol/symfind.cc @@ -128,11 +128,10 @@ finalize_symbol_map2() { for( auto& elem : symbol_map2 ) { auto& fields( elem.second ); - std::remove_if( fields.begin(), fields.end(), - []( auto isym ) { - auto f = cbl_field_of(symbol_at(isym)); - return f->type == FldInvalid; - } ); + fields.remove_if( []( auto isym ) { + auto f = cbl_field_of(symbol_at(isym)); + return f->type == FldInvalid; + } ); if( fields.empty() ) empties.insert(elem.first); }