From b20c23359960934062f96d714ea3bd8f682085e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 5 Nov 2008 07:48:07 +0000 Subject: [PATCH] TestBufferOverrun: Added a test case that shouldn't generate error. Get address beyond array. --- testbufferoverrun.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/testbufferoverrun.cpp b/testbufferoverrun.cpp index bb2ebc05b..c346a196e 100644 --- a/testbufferoverrun.cpp +++ b/testbufferoverrun.cpp @@ -1,4 +1,4 @@ -/* +/* * c++check - c/c++ syntax checking * Copyright (C) 2007 Daniel Marjamäki * @@ -62,6 +62,9 @@ private: TEST_CASE( noerr2 ); TEST_CASE( noerr3 ); + // Todo: Fix this. + //TEST_CASE( noerr4 ); + TEST_CASE( array_index_1 ); TEST_CASE( array_index_2 ); TEST_CASE( array_index_3 ); @@ -131,6 +134,18 @@ private: } + void noerr4() + { + // The memory isn't read or written and therefore there is no error. + check( "static void f()\n" + "{\n" + " char data[100];\n" + " const char *p = &data[100];\n" + "}\n" ); + ASSERT_EQUALS( std::string(""), errout.str() ); + } + + void array_index_1() { check("void f()\n"