Bug 329613

Summary: Missing warning "Value of local variable is not used"
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Deepak Azad CLA 2010-11-06 11:06:26 EDT
Test failures JDT UI in build N20101105-2000
http://download.eclipse.org/eclipse/downloads/drops/N20101105-2000/testresults/xml/org.eclipse.jdt.ui.tests_win32.win32.x86_6.0.xml

In the following snippet value of 'a' is not used, but the compiler does not report any warning.

package test1;
public class E {
    private void foo() {
        int a= 10;
        a++;
        a--;
        --a;
        ++a;
        for ( ; ; a++) {
        }
    }
}
Comment 1 Olivier Thomann CLA 2010-11-06 11:19:55 EDT
Stephan, I am assigning it to you. Let me know if you are willing to work on it.
Thanks.
Comment 2 Stephan Herrmann CLA 2010-11-06 15:01:49 EDT
I'd be happy to fix this, but on my machine it ain't broken.

More specifically: my base is a fresh SDK 3.7M3, workspace contains
- jdt.core v_B22 (which was also used in N20101105-2000)
- jdt.ui.tests HEAD
- and a few more

Running LocalCorrectionsQuickFixTest yields 100% pass (161/161).

Moreover, according to the map files the following builds have not differences
in jdt land:
  I20101102-0800 (no test failures)
  N20101105-2000 (failures in LocalCorrectionsQuickFixTest)

Simplest way to create the bug is by deleting these lines in tests:

  JavaCore.setOptions(hashtable);

Thus, it *might* be another hint that setting JavaCore options has a rarely
triggered racing condition (cf. bug 302850).
Comment 3 Deepak Azad CLA 2010-11-07 00:29:52 EDT
(In reply to comment #2)
> I'd be happy to fix this, but on my machine it ain't broken.
> 
> More specifically: my base is a fresh SDK 3.7M3, workspace contains
> - jdt.core v_B22 (which was also used in N20101105-2000)
> - jdt.ui.tests HEAD
> - and a few more
> 
> Running LocalCorrectionsQuickFixTest yields 100% pass (161/161).
> 
> Moreover, according to the map files the following builds have not differences
> in jdt land:
>   I20101102-0800 (no test failures)
>   N20101105-2000 (failures in LocalCorrectionsQuickFixTest)
Nightly builds are run against the latest code in HEAD. Only Integration builds depend on map files. (http://download.eclipse.org/eclipse/downloads/build_types.html)
Comment 4 Stephan Herrmann CLA 2010-11-07 00:55:51 EDT
(In reply to comment #3)
> Nightly builds are run against the latest code in HEAD. Only Integration builds
> depend on map files.
> (http://download.eclipse.org/eclipse/downloads/build_types.html)

Sorry, yes (I was just misled by the mapfile link on the download page).

Indeed the failures can only be reproduced with the patch from 
bug 328519 comment 11. HEAD is not affected currently, because Olivier
reverted that patch.
Comment 5 Olivier Thomann CLA 2010-11-07 10:57:22 EST
I think we can close this one as being a side-effect of a wrong fix for bug 328519.
I need to work more on bug 328519 to support the case where we tag a variable as USED only because we have preserveAllLocals option enabled.
Even if this option is enabled, we should still generate the warning.

Closing as INVALID
Comment 6 Ayushman Jain CLA 2010-12-07 01:58:56 EST
Verified for 3.7M4.