Community
Participate
Working Groups
To reproduce select the marked line in the code bellow and try to extract a function. The signature of the extracted function is "A* extracted(int* x)", which is an indication that CDT thinks that x can be modified by the A(x) call. struct A { A(int s); }; int test() { int x; A* a = new A(x); // Select this line delete a; return x; }
The problem stems from the fact that A(x) gets resolved to CPPClassType A instead of CPPConstructor A. As a result getExpressionType() on the containing IASTIdExpression returns EvalFixed.INCOMPLETE. This causes confusion of VariableReadWriteFlags.rwArgumentForFunctionCall(IASTFunctionCallExpression, IASTNode, int) method, which decides to play safe and returns READ | WRITE.
Fixed by commit http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?h=cdt_8_1&id=add4edd847636d91be922df9c5d91398d4d29d5d.
Another change related to this bug: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=679683b6c952990e70c413be7cbe438043cf2f3b
*** cdt git genie on behalf of Sergey Prigogin *** Bug 393068 - Constructor call is treated as write access for arguments [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=cfd9acad9531149754b4292161f45a8c305a32af
*** cdt git genie on behalf of Sergey Prigogin *** Bug 393068 - Constructor call is treated as write access for arguments [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=add4edd847636d91be922df9c5d91398d4d29d5d
*** cdt git genie on behalf of Sergey Prigogin *** Bug 393068 - Constructor call is treated as write access for arguments [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=679683b6c952990e70c413be7cbe438043cf2f3b
*** cdt git genie on behalf of Sergey Prigogin *** Bug 393068 - Constructor call is treated as write access for arguments [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=81c9f2d7555147406dc00e29e4641d409e89a0c9