MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / scope

Method scope

test/testbufferoverrun.cpp:5144–5168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5142 }
5143
5144 void scope() {
5145 check("class A {\n"
5146 "private:\n"
5147 " struct X { char buf[10]; };\n"
5148 "};\n"
5149 "\n"
5150 "void f()\n"
5151 "{\n"
5152 " X x;\n"
5153 " x.buf[10] = 0;\n"
5154 "}");
5155 ASSERT_EQUALS("", errout_str());
5156
5157 check("class A {\n"
5158 "public:\n"
5159 " struct X { char buf[10]; };\n"
5160 "};\n"
5161 "\n"
5162 "void f()\n"
5163 "{\n"
5164 " A::X x;\n"
5165 " x.buf[10] = 0;\n"
5166 "}");
5167 ASSERT_EQUALS("[test.cpp:9:10]: (error) Array 'x.buf[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
5168 }
5169
5170 void getErrorMessages() {
5171 // Ticket #2292: segmentation fault when using --errorlist

Callers 15

checkRecursiveMethod · 0.80
isSimpleIndexExpressionFunction · 0.80
possiblyAliasedMethod · 0.80
isPointerDeRefMethod · 0.80
arrayIndexMethod · 0.80
doAssignmentFunction · 0.80
assertWithSideEffectsMethod · 0.80
inSameScopeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected