]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Fix incorrect use of std::remove_if
authorJonathan Wakely <jwakely@redhat.com>
Tue, 18 Mar 2025 18:37:01 +0000 (18:37 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 2 Apr 2025 09:40:20 +0000 (10:40 +0100)
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.

gcc/cobol/symfind.cc

index 2687fdb83df2f82f651c543d1750819bffd50967..899571551e8fd1bf70aa72df589e4aae83562dd6 100644 (file)
@@ -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);
   }