Improve test coverage for detecting invalid pointers
This commit is contained in:
parent
85a26802e3
commit
b61feff125
|
@ -2813,6 +2813,13 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x+i' is out of bounds.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x+i' is out of bounds.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f(int i) {\n"
|
||||||
|
" char x[10];\n"
|
||||||
|
" if (i == -1) {}\n"
|
||||||
|
" dostuff(x+i);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (portability) Undefined behaviour, when 'i' is -1 the pointer arithmetic 'x+i' is out of bounds.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n" // #6350 - fp when there is cast of buffer
|
check("void f() {\n" // #6350 - fp when there is cast of buffer
|
||||||
" wchar_t buf[64];\n"
|
" wchar_t buf[64];\n"
|
||||||
" p = (unsigned char *) buf + sizeof (buf);\n"
|
" p = (unsigned char *) buf + sizeof (buf);\n"
|
||||||
|
|
Loading…
Reference in New Issue