Skip to content

Commit 469ab56

Browse files
dpbainesvaughnbetz
authored andcommitted
Commenting fix for negative check
1 parent 35d2e17 commit 469ab56

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libs/libvtrutil/src/vtr_vector_map.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class vector_map {
6262
//Indexing
6363
const_reference operator[](const K n) const {
6464
size_t index = size_t(n);
65+
66+
// Shouldn't check for index >= 0, since size_t is unsigned thus won't be negative
67+
// A negative input to n would result in an absurdly large number close the maximum size of size_t, and be caught by index < vec_.size()
68+
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf chapter 4.7 para 2
69+
6570
VTR_ASSERT_SAFE_MSG(index < vec_.size(), "Out-of-range index");
6671
return vec_[index];
6772
}

0 commit comments

Comments
 (0)