Skip to content

fixed: up to 3 cells are added, so resize to 3 to avoid oob warnings#996

Open
akva2 wants to merge 1 commit intoOPM:masterfrom
akva2:janitoring_quell_oob
Open

fixed: up to 3 cells are added, so resize to 3 to avoid oob warnings#996
akva2 wants to merge 1 commit intoOPM:masterfrom
akva2:janitoring_quell_oob

Conversation

@akva2
Copy link
Member

@akva2 akva2 commented Mar 3, 2026

also, use std::array

i'm not entirely sure if this is the correct fix or if there is a logic error here, but it definitely is wrong as-is.

@akva2 akva2 added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Mar 3, 2026
@akva2
Copy link
Member Author

akva2 commented Mar 3, 2026

jenkins build this please

@akva2 akva2 force-pushed the janitoring_quell_oob branch from 1c62b6b to 99a637e Compare March 3, 2026 10:29
@akva2
Copy link
Member Author

akva2 commented Mar 3, 2026

hmm, did not improve things.

use std::vector. not sure what gcc is complaining about here
@akva2 akva2 force-pushed the janitoring_quell_oob branch from 99a637e to 41ad4ac Compare March 3, 2026 10:57
@akva2
Copy link
Member Author

akva2 commented Mar 3, 2026

jenkins build this please

@akva2
Copy link
Member Author

akva2 commented Mar 3, 2026

this is the only way i could make it shut up. i also note that we cannot use the constrained algorithm since weak_ordering fails for the EntityRep.

@bska
Copy link
Member

bska commented Mar 3, 2026

hmm, did not improve things.

Tangential note and I don't know if it's related, but for what it's worth, Issue #505 happened to be in the same area.

@blattms
Copy link
Member

blattms commented Mar 4, 2026

Then maybe try if #935 fixes this?

@akva2
Copy link
Member Author

akva2 commented Mar 5, 2026

it does not, with that PR it still goes chatty;

n file included from /home/akva/kode/opm/opm-grid/opm/grid/cpgrid/Geometry.hpp:51,
                 from /home/akva/kode/opm/opm-grid/opm/grid/cpgrid/CpGridData.hpp:72,
                 from /home/akva/kode/opm/opm-grid/opm/grid/cpgrid/processEclipseFormat.cpp:40:
In member function ‘int Dune::cpgrid::EntityRep<codim>::index() const [with int codim = 0]’,
    inlined from ‘bool Dune::cpgrid::EntityRep<codim>::operator<(const Dune::cpgrid::EntityRep<codim>&) const [with int codim = 0]’ at /home/akva/kode/opm/opm-grid/opm/grid/cpgrid/EntityRep.hpp:169:37,
    inlined from ‘constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = Dune::cpgrid::EntityRep<0>*; _Iterator2 = Dune::cpgrid::EntityRep<0>*]’ at /usr/include/c++/14/bits/predefined_ops.h:45:23,
    inlined from ‘constexpr void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = Dune::cpgrid::EntityRep<0>*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ at /usr/include/c++/14/bits/stl_algo.h:88:17,
    inlined from ‘constexpr _RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Dune::cpgrid::EntityRep<0>*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ at /usr/include/c++/14/bits/stl_algo.h:1855:34,
    inlined from ‘constexpr void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = Dune::cpgrid::EntityRep<0>*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ at /usr/include/c++/14/bits/stl_algo.h:1889:38,
    inlined from ‘constexpr void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Dune::cpgrid::EntityRep<0>*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ at /usr/include/c++/14/bits/stl_algo.h:1905:25,
    inlined from ‘constexpr void std::sort(_RAIter, _RAIter) [with _RAIter = Dune::cpgrid::EntityRep<0>*]’ at /usr/include/c++/14/bits/stl_algo.h:4771:18,
    inlined from ‘void Dune::{anonymous}::buildFaceToCell(const processed_grid&, const Dune::NNCMaps&, const std::vector<int>&, Dune::cpgrid::OrientedEntityTable<1, 0>&, std::vector<int>&)’ at /home/akva/kode/opm/opm-grid/opm/grid/cpgrid/processEclipseFormat.cpp:1167:30:
/home/akva/kode/opm/opm-grid/opm/grid/cpgrid/EntityRep.hpp:127:24: warning: array subscript [8, 1152921504606846975] is outside array bounds of ‘Dune::cpgrid::EntityRep<0> [2]’ [-Warray-bounds=]
  127 |                 return entityrep_ < 0 ? ~entityrep_ : entityrep_;
      |                        ^~~~~~~~~~
/home/akva/kode/opm/opm-grid/opm/grid/cpgrid/processEclipseFormat.cpp: In function ‘void Dune::{anonymous}::buildFaceToCell(const processed_grid&, const Dune::NNCMaps&, const std::vector<int>&, Dune::cpgrid::OrientedEntityTable<1, 0>&, std::vector<int>&)’:
/home/akva/kode/opm/opm-grid/opm/grid/cpgrid/processEclipseFormat.cpp:1114:34: note: at offset [32, 4611686018427387900] into object ‘cells’ of size 8
 1114 |             cpgrid::EntityRep<0> cells[2];
      |                                  ^~~~

@akva2
Copy link
Member Author

akva2 commented Mar 12, 2026

your comment apparently disappeared, but I have not triggered any runtime issues, it's just trying to address the compiler warning.

@blattms
Copy link
Member

blattms commented Mar 12, 2026

I deleted it, because I realized that it is not at runtime.

Isn't this a false positive as at the place were gcc actually warns (EntityRep::index()) there is no array subscript? There have been quite a few of those for other libraries, too.

I also did not find a way how 3 cells could be added here, but I might have missed something...

@akva2
Copy link
Member Author

akva2 commented Mar 12, 2026

basically, line 1121, line 1125, and line 1137. there may be logic so we never hit all 3 but the compiler apparently cannot see it. it was my theory anyways. i know it's been there for a while but i am/was trying to bring the compiler warning number down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants