#6671 false positive: incorrect sizeofwithsilentarraypointer with reference to array.

This commit is contained in:
Alexander Mai 2015-05-06 07:38:26 +02:00
parent 97f998e6dd
commit 1c5e9e47c5
2 changed files with 9 additions and 1 deletions

View File

@ -78,7 +78,7 @@ void CheckSizeof::checkSizeofForArrayParameter()
}
const Variable *var = varTok->variable();
if (var && var->isArray() && var->isArgument())
if (var && var->isArray() && var->isArgument() && !var->isReference())
sizeofForArrayParameterError(tok);
}
}

View File

@ -181,6 +181,14 @@ private:
ASSERT_EQUALS("[test.cpp:2]: (warning) Using 'sizeof' on array given as "
"function argument returns size of a pointer.\n", errout.str());
check("typedef char Fixname[1000];\n"
"int f2(Fixname& f2v) {\n"
" int i = sizeof(f2v);\n"
" printf(\"sizeof f2v %d\n\", i);\n"
" }\n"
);
ASSERT_EQUALS("", errout.str());
check("void f(int *p) {\n"
" p[0] = 0;\n"
" int unused = sizeof(p);\n"