Summary: | [compiler] Suppress "Dead Code" warning if code block is protected by "if(0==1)" | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Aaron Digulla <digulla> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED WONTFIX | QA Contact: | |
Severity: | enhancement | ||
Priority: | P5 | CC: | amj87.iitr, Olivier_Thomann, stephan.herrmann |
Version: | 3.5 | ||
Target Milestone: | 3.6 M3 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Aaron Digulla
2009-09-25 03:25:28 EDT
Please see bug 256463. Wouldn't the pattern supported in 3.5 work for you, too? (hint: use a constant) Why not simply using "if (false) ..."? This won't be different from what you are writing. (In reply to comment #2) > Why not simply using "if (false) ..."? > This won't be different from what you are writing. Yes, it would be: I would have to change more than a single character to flip the condition. Also the chance to encounter "if (0 == 1)" anywhere else in the code is pretty low which makes it a good candidate to guard debug code. (In reply to comment #1) > Please see bug 256463. > > Wouldn't the pattern supported in 3.5 work for you, too? > (hint: use a constant) Thanks for the hint. It solves half of my problem (my second case above works with 3.5; I didn't actually try it before reporting the bug). So my bug report is now to allow "if (0 == 1)" in addition to what bug 256463 fixes. I'd rather track this with a new bug since bug 256463 is already closed. The chances should not be higher to encounter "if (false)...". (In reply to comment #5) > The chances should not be higher to encounter "if (false)...". Then do it. With "if (false)", you have to select "false" and replace it with "true". That's four to nine keys pressed. With "if (0 == 1)", it's two keys: Select or delete the "0", press "1". Which one is less work? :) (In reply to comment #6) > (In reply to comment #5) > > The chances should not be higher to encounter "if (false)...". > > Then do it. With "if (false)", you have to select "false" and replace it with > "true". That's four to nine keys pressed. > > With "if (0 == 1)", it's two keys: Select or delete the "0", press "1". > > Which one is less work? :) If you're really concerned about a few keystrokes, why don't you let "!" be your friend? ;-) DEBUG = true; if (DEBUG) stmt; edit DEBUG = !true; Sound much easier than introducing more heuristics into the tool, no? We cannot support everyone's dead code pattern. I believe we support the more comment ones. This is clearly low priority. Feel free to provide a patch. Closing as WONTFIX. No plan to add this code pattern. if (DEBUG) or if (!DEBUG) is sufficient. We don't want to add special cases for each of the existing code patterns. Verified for 3.6M3 |