Bug 455923 - [compiler] code incorrectly flagged as "dead"
Summary: [compiler] code incorrectly flagged as "dead"
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2014-12-21 17:05 EST by Dave Dyer CLA
Modified: 2022-06-29 10:57 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 Dave Dyer CLA 2014-12-21 17:05:39 EST
This program incorrectly flags the second clause in "doit1" as
dead.  Run the program to see that it is not.  "doit2" is a slightly
rewritten version of the same function which is not flagged.

package test;

public class ReadStock {
	int actualVotes;
	public ReadStock(int w)
	{	actualVotes = w;
	}
	
	static public void doit1(ReadStock players[])
	{
	ReadStock winner = null;
	ReadStock tie = null;
	
	for(ReadStock p : players)
	{

			if((winner==null)||(p.actualVotes>=winner.actualVotes))
			{	tie = winner;
				winner = p;
			}
	
	}
	if((tie!=null)
		&& (winner!=null) 
		&& (tie.actualVotes==winner.actualVotes))
		{ //incorrectly flagged as dead
                  System.out.println("It's a tie 1");
		}
	}
	
	static public void doit2(ReadStock players[])
	{
	ReadStock winner = null;
	ReadStock tie = null;

	for(ReadStock p : players)
	{
		{	if(winner==null) { winner = p; }
			else if(p.actualVotes>=winner.actualVotes) 
			{	tie = winner;
				winner = p;
			}
		}
	}
	if((tie!=null)
			&& (winner!=null) 
			&& (tie.actualVotes==winner.actualVotes))
		{ System.out.println("Its a tie 2");
		}
	}

	public static void main(String args[])
	{	ReadStock players[] = { new ReadStock(1),new ReadStock(1)};
		doit1(players);
		doit2(players);
	}
}
Comment 1 Stephan Herrmann CLA 2014-12-22 10:25:51 EST
This example is accepted by ecj <= 3.6.2 and rejected above.
Comment 2 Stephan Herrmann CLA 2015-05-13 17:29:23 EDT
I'll check for RC2 if there's a safe fix, but will more likely move over to 4.6 ...

... even though at 3.7 it was a regression ...
Comment 3 Jay Arthanareeswaran CLA 2015-05-26 00:15:32 EDT
Moving to 4.6.
Comment 4 Stephan Herrmann CLA 2016-03-25 10:30:58 EDT
Too much on my plate for 4.6. Bulk deferral to 4.7
Comment 5 Manoj N Palat CLA 2018-04-16 09:32:00 EDT
bulk move out of 4.8
Comment 6 Manoj N Palat CLA 2018-08-16 00:07:08 EDT
Bulk move out of 4.9
Comment 7 Eclipse Genie CLA 2022-06-29 10:57:38 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.