| Summary: | Wrong write access for arguments of constructor and array initializers. | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Andrey Eremchenko <kamre> | ||||||
| Component: | cdt-parser | Assignee: | Markus Schorn <mschorn.eclipse> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | cdtdoug, malaperle, paedu.hofer, yevshif | ||||||
| Version: | 8.0 | ||||||||
| Target Milestone: | 8.0.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
One more simple case with wrong write access:
void f()
{
int i;
int a[2] = { 0, i }; // here i is marked with write access
}
Created attachment 182271 [details]
patch
fixes both examples
(In reply to comment #2) > Created an attachment (id=182271) [details] > patch > fixes both examples The fix is not correct, changing the ctor to: A(int& p) {} should turn this into a write access. So far the use of an expression as an argument triggers a (potential) write access. Similar a list-initializer used for initializing a class can cause a write access to a member of the list. Markus, could you give me some detailed hints on how to solve this in a proper way? I'd like to have this fixed for Indigo. Thanks, Patrick (In reply to comment #4) > Markus, > could you give me some detailed hints on how to solve this in a proper way? > I'd like to have this fixed for Indigo. > Thanks, Patrick To fix the two examples in comment 0, in the method VariableReadWriteFlags.rwAnyNode() you need to consider parents of type ICPPASTConstructorInitializer and IASTInitializerList. For the former the handling should be similar to what is done for a function call, for the latter similar to the IASTEqualsInitializer. (In reply to comment #5) Thanks, this is helpful. I'm working on the code now. Created attachment 196828 [details]
Unfinished patch
Markus, can you review this?
I'm not certain that I have understood how to solve this bug properly. There are TODO/FIXME tags in the patch which indicate where I could use some help.
Do we need to introduce ICPPASTCtorCallExpression and CPPASTCtorCallExpression? That would be unfortunate since API freeze for Indigo is over.
(In reply to comment #7) > Created attachment 196828 [details] > Unfinished patch > Markus, can you review this? > I'm not certain that I have understood how to solve this bug properly. There > are TODO/FIXME tags in the patch which indicate where I could use some help. > Do we need to introduce ICPPASTCtorCallExpression and CPPASTCtorCallExpression? > That would be unfortunate since API freeze for Indigo is over. I am sure we don't have to introduce new API. I'll have a look at your work, however it is too late for 8.0 anyways. I did not use the patch. Added testcases to IndexNamesTests, fixed in 8.0.1 and 8.1. |
Build Identifier: 8.0 Sample code: class A { public: A(int p) {} }; int main(int argc, char **argv) { int p = 0; A a(p); // here p is marked with write access return 0; } Reproducible: Always