Using GCC Undefined Behavior Sanitizer (enable by compiling with -fsanitize=undefined) on an instance of the Solomon benchmark results in:
/usr/include/c++/7/bits/stl_vector.h:816:34: runtime error: reference binding to null pointer of type 'const struct value_type'
structures/vroom/tw_route.cpp:453:43: runtime error: reference binding to null pointer of type 'const struct Break'
Because there is no break in input, the mentioned line:
|
const auto& b = v.breaks[current_break]; |
defines a reference to the first element of an empty vector. In that case, the surrounding loop is designed in such a way that this reference is not actually used when the vector is empty, but this is still UB all right.
We should:
- investigate other potential runtime reports using other input examples
- fix spotted UB
- setup a way to check this periodically in the long run
No really sure how to go for that last point because setting -fsanitize=undefined slows down things to such a degree that it is totally not practically usable in dev mode.
Using GCC Undefined Behavior Sanitizer (enable by compiling with
-fsanitize=undefined) on an instance of the Solomon benchmark results in:Because there is no break in input, the mentioned line:
vroom/src/structures/vroom/tw_route.cpp
Line 453 in b5dd59d
defines a reference to the first element of an empty vector. In that case, the surrounding loop is designed in such a way that this reference is not actually used when the vector is empty, but this is still UB all right.
We should:
No really sure how to go for that last point because setting
-fsanitize=undefinedslows down things to such a degree that it is totally not practically usable in dev mode.