We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 35d2e17 commit 469ab56Copy full SHA for 469ab56
libs/libvtrutil/src/vtr_vector_map.h
@@ -62,6 +62,11 @@ class vector_map {
62
//Indexing
63
const_reference operator[](const K n) const {
64
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
70
VTR_ASSERT_SAFE_MSG(index < vec_.size(), "Out-of-range index");
71
return vec_[index];
72
}
0 commit comments