Open edigiacomo opened 1 year ago
When _GLIBCXX_ASSERTIONS is set (see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html), Magics sometimes throws a runtime error:
_GLIBCXX_ASSERTIONS
/usr/include/c++/12/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
The runtime error are raised when some instance methods are invoked on an empty vector, e.g. operator[] or front(). This PR tries to fix some of these potential errors, resizing the vector before populating it or using insert instead of operator[].
operator[]
front()
insert
See https://jira.ecmwf.int/plugins/servlet/desk/portal/4/SD-80581 for more details.
All committers have signed the CLA.
Kudos, SonarCloud Quality Gate passed!
0 Bugs 0 Vulnerabilities 0 Security Hotspots 0 Code Smells
No Coverage information No Duplication information
When
_GLIBCXX_ASSERTIONS
is set (see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html), Magics sometimes throws a runtime error:The runtime error are raised when some instance methods are invoked on an empty vector, e.g.
operator[]
orfront()
. This PR tries to fix some of these potential errors, resizing the vector before populating it or usinginsert
instead ofoperator[]
.See https://jira.ecmwf.int/plugins/servlet/desk/portal/4/SD-80581 for more details.