From 7c95c6f6801a5cb2a017e2b52626d575afda0579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Dec 2011 16:43:46 +0100 Subject: [PATCH] Array index out of bounds: Added test case for #3428 (same name of structs) --- test/testbufferoverrun.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 1313ea8c4..529bc57b2 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -1331,6 +1331,17 @@ private: " struct Fred { char data[3]; } fred;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void a() {\n" + " struct Fred { char data[6]; } fred;\n" + " fred.data[4] = 0;\n" // <- no error + "}\n" + "\n" + "void b() {\n" + " struct Fred { char data[3]; } fred;\n" + " fred.data[4] = 0;\n" // <- error + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Array 'fred.data[3]' index 4 out of bounds\n", errout.str()); } void array_index_multidim() {