addition of unsigned offset to 0x602000000130 overflowed to 0x60200000012c (stl_vector.h)

Line 1034: Char 34: runtime error: addition of unsigned offset to 0x602000000130 overflowed to 0x60200000012c (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34

今天做leetcode第283题 移动零力扣的时候出现上述错误,如下图:

将代码复制到本地IDE CLion中调试,发现有出现vector下标为-1的情况,造成栈溢出,如下图:

addition of unsigned offset to 0x602000000130 overflowed to 0x60200000012c (stl_vector.h)_第1张图片 

 检查下标即可解决上述问题

你可能感兴趣的:(Leetcode,c++,开发语言)