Community
Participate
Working Groups
Build Identifier: Eclipse I20110613-1736 CDT 8.0 This is a reopen of bug 307414 For the statement: if( a == 1 && b = 2 ) The whole expression "a == 1 && b = 2" is marked and not only "b = 2", because of this, the quick fix does the following wrong fix: if( a === 1 && b = 2 ) See comments 6 & 7 in 307414. Reproducible: Always
Let me remind that this happens because it is parsed as (a == 1 && b) = 2. I agree that this needs to be cleverly handled. More test similar cases would be useful. Can you think of any similar but different situations where substituting = by == would change the operator order?
(In reply to comment #1) > Let me remind that this happens because it is parsed as (a == 1 && b) = 2. I > agree that this needs to be cleverly handled. > > More test similar cases would be useful. Can you think of any similar but > different situations where substituting = by == would change the operator > order? This warning is predicated on the assumption that the user intended == rather than =. It follows, then, that the user also intended the precedence that comes with == rather than the precedence that comes with =.
Patch: https://git.eclipse.org/r/14764
*** cdt git genie on behalf of Nathan Ridge *** Bug 352267 - Assignment in condition checker matches the whole expression Change-Id: I7aea1c5d404a8d374020e34c997e6e890fcdb3d6 Signed-off-by: Nathan Ridge <zeratul976@xxxxxxxxxxx> Reviewed-on: <a href="https://git.eclipse.org/r/14764">https://git.eclipse.org/r/14764</a> Reviewed-by: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> IP-Clean: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> Tested-by: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=bb84b5cba3e1948297c22ed4f327a2e74973c6da
Fixed in 8.2.1 and master.
Verified in 8.2.1 RC1 (EPP 20130821-2252).