Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 228665

Summary: Incorrect comment
Product: [Eclipse Project] JDT Reporter: Caleb <calebcjh>
Component: UIAssignee: platform-ua-inbox <platform-ua-inbox>
Status: CLOSED INVALID QA Contact:
Severity: minor    
Priority: P3 CC: cgold, deepakazad
Version: 3.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Caleb CLA 2008-04-24 09:17:26 EDT
When the following code is entered:

int k = 1;
k = ++k;

Eclipse incorrectly indicates an error with the message "The assignment to variable k has no effect" when actually, k has been incremented after those two statements.

The code:

int m = 2;
m = m++;

does not have any effect, but is not detected by Eclipse as the above-mentioned message did not show up.
Comment 1 Chris Goldthorpe CLA 2008-04-24 10:02:22 EDT
Assigning to JDT
Comment 2 Deepak Azad CLA 2010-05-17 15:14:00 EDT
(In reply to comment #0)
> When the following code is entered:
> 
> int k = 1;
> k = ++k;
> 
> Eclipse incorrectly indicates an error with the message "The assignment to
> variable k has no effect" when actually, k has been incremented after those two
> statements.

int k = 1;
++k;
This is same as above code, k is 2 in both cases

> The code:
> 
> int m = 2;
> m = m++;
> 
> does not have any effect, but is not detected by Eclipse as the above-mentioned
> message did not show up.
In this case m is 2.

int m = 2;
m++;
In this case m becomes 3. 

Note the difference in post increment and pre increment operators.