diff --git a/opm/core/ColumnExtract.hpp b/opm/core/ColumnExtract.hpp index 5a4cdc76..51916923 100644 --- a/opm/core/ColumnExtract.hpp +++ b/opm/core/ColumnExtract.hpp @@ -62,7 +62,8 @@ void extractColumn( const UnstructuredGrid& grid, std::pair, st columns.second[local_index].push_back(i); } - for(int i = 0; i < columns.second.size(); ++i) { + int num_cols = columns.second.size(); + for(int i = 0; i < num_cols; ++i) { std::sort(columns.second[i].begin(), columns.second[i].end(), ExtractColumnCompare(grid)); } }