Skip to content

Commit 0d1d3b4

Browse files
Add regression test for #10458 (#3555)
1 parent 5341cb2 commit 0d1d3b4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,6 +3129,22 @@ class TestBufferOverrun : public TestFixture {
31293129
" int *p = s->a + 100;\n"
31303130
"}");
31313131
ASSERT_EQUALS("[test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic 's->a+100' is out of bounds.\n", errout.str());
3132+
3133+
check("template <class T> class Vector\n"
3134+
"{\n"
3135+
"public:\n"
3136+
" void test() const;\n"
3137+
" T* data();\n"
3138+
"};\n"
3139+
"template <class T>\n"
3140+
"void Vector<T>::test() const\n"
3141+
"{\n"
3142+
" const T* PDat = data();\n"
3143+
" const T* P2 = PDat + 1;\n"
3144+
" const T* P1 = P2 - 1;\n"
3145+
"}\n"
3146+
"Vector<std::array<long, 2>> Foo;\n");
3147+
ASSERT_EQUALS("", errout.str());
31323148
}
31333149

31343150
void pointer_out_of_bounds_4() {

0 commit comments

Comments
 (0)