Closed Jannik2099 closed 1 year ago
See also robotastic/trunk-recorder#782
Even though you are only using the address of the vector[0], you were still dereferencing it first via operator[], which is UB if the index does not exist. Using iterators fixes this as vector.begin() returns vector.end() if vector.size() is 0.
vector[0]
operator[]
vector.begin()
vector.end()
vector.size()
CC @ZeroChaos-
See also robotastic/trunk-recorder#782
Even though you are only using the address of the
vector[0]
, you were still dereferencing it first viaoperator[]
, which is UB if the index does not exist. Using iterators fixes this asvector.begin()
returnsvector.end()
ifvector.size()
is 0.CC @ZeroChaos-