Repository navigation
Fix #11599 false negative: constParameter - #4902
Conversation
| "void f(int* p) {\n" | ||
| " return g(&p);\n" | ||
| "}\n"; | ||
| ASSERT_EQUALS(false, isVariableChangedByFunctionCall(code, "p ) ;", &inconclusive)); |
There was a problem hiding this comment.
This should be true because the indirect will be set to 1, which will check that the data is modified and not the pointer.
There was a problem hiding this comment.
If indirect is set to 0 then it should be false.
There was a problem hiding this comment.
With the new formula and indirect always 0 (as it was before), this fails:
code = "void g(int a[2]);\n"
"void f() {\n"
" int b[2] = {};\n"
" return g(b);\n"
"}\n";
ASSERT_EQUALS(true, isVariableChangedByFunctionCall(code, "b ) ;", &inconclusive));
ASSERT_EQUALS(true, inconclusive);
There was a problem hiding this comment.
We need to check for array and up the indirection since arrays are passed by pointer and not by value, I assume.
There was a problem hiding this comment.
Well, a std::array can be passed by value, and since we like to conflate those...
There was a problem hiding this comment.
inconclusive was not reset (it is only ever set to true, never false.
So inconclusive is true if we haven't seen a declaration at all, but false if there is a possibly-changing declaration. Shouldn't the result also depend on the function's definition?
There was a problem hiding this comment.
That's one of the things I want to address with the work started in #4798.
|
Needs to be rebased. |
|
Is this OK to be merged? |
No description provided.