Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347192 - "The local variable is never read" warning is not shown after "if (true) return"
Summary: "The local variable is never read" warning is not shown after "if (true) return"
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-25 12:51 EDT by ivan.vergiliev CLA
Modified: 2022-08-07 18:31 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ivan.vergiliev CLA 2011-05-25 12:51:38 EDT
Build Identifier: 20110124_1224

In the following code:

void f() {
    if (true) {
	return;
    }
    int a = 5;
}

no warning is shown about the variable a not being read.
If I add "a = a;" afterwards, I do get a "The assignment to variable a has no effect" warning.

Reproducible: Always
Comment 1 Olivier Thomann CLA 2011-05-25 13:24:45 EDT
Since the code is never generated, the warning is not reported.
If you enable the warning for dead code, you would get a dead code warning.

The generation of this warning will be revisited for 3.8.
Comment 2 ivan.vergiliev CLA 2011-05-25 13:31:04 EDT
My point with the last line was that if I write this:

void f() {
    if (true) {
	return;
    }
    int a = 5;
    a = a;
}

I do get a warning about a = a, even though that code is supposedly not generated - meaning that only some warnings are hidden, not all.
Comment 3 Olivier Thomann CLA 2011-08-24 12:23:14 EDT
This just depends at what moment in the compilation process the warning is reported. The warning for local variable being unread is right now generated at the code generation time. Some others warnings are reported during type resolution.
Stephan, do you think we can tackle this one with the changes you wanted to make into the code analysis ?
Comment 4 Stephan Herrmann CLA 2011-08-25 09:15:43 EDT
(In reply to comment #3)
> Stephan, do you think we can tackle this one with the changes you wanted to
> make into the code analysis ?

Were you thinking about the group around bug 328830?

I'll look at it once some of the other bugs with work in progress
are resolved.
Comment 5 Stephan Herrmann CLA 2012-01-29 06:55:35 EST
Not much I can do without a solution in bug 328830. That one, however, should better be addressed in some M1 or M2 at the latest.
Comment 6 Eclipse Genie CLA 2022-08-07 18:31:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.