Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v --- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 17 Jun 2009 06:44:14 -0000 1.16 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 16 Jul 2009 06:07:48 -0000 @@ -1529,4 +1529,34 @@ "Zork cannot be resolved to a type\n" + "----------\n"); } +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=281776" + * We now tolerate comparison of float and double entities against + * themselves as a legitimate idiom for NaN checking. + */ +public void test0040() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " double var = Double.NaN;\n" + + " if(var != var) {\n" + + " System.out.println(\"NaN\");\n" + + " }\n" + + " float varf = 10;\n" + + " if(varf != varf) {\n" + + " System.out.println(\"NaN\");\n" + + " }\n" + + " }\n" + + " Zork z;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 12)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n"); +} } Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v --- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 17 Jun 2009 06:44:02 -0000 1.74 +++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 16 Jul 2009 06:08:03 -0000 @@ -812,7 +812,8 @@ // check whether comparing identical expressions Binding leftDirect = Expression.getDirectBinding(this.left); if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) { - scope.problemReporter().comparingIdenticalExpressions(this); + if (leftTypeID != TypeIds.T_double && leftTypeID != TypeIds.T_float) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=281776 + scope.problemReporter().comparingIdenticalExpressions(this); } else if (this.constant != Constant.NotAConstant) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740 int operator = (this.bits & OperatorMASK) >> OperatorSHIFT;