comparison-with-nan-literal
Status: stub. The full-length analysis is queued for a v1.0.x patch release per ADR 0018, section 5, criterion #6. The companion rule page at docs/rules/comparison-with-nan-literal.md contains the canonical detection logic + GPU reasoning.
TL;DR
IEEE 754 mandates that every ordered comparison involving a NaN operand returns false, and every unordered comparison returns true. This means x < (0.0 / 0.0) is unconditionally false for all finite, infinite, and NaN values of x — including when x is itself NaN. The comparison is a constant, not a runtime test.
What the rule fires on
Any comparison (==, !=, <, <=, >, >=) whose left or right operand is a literal NaN-producing expression. The canonical forms are 0.0 / 0.0 (zero divided by zero), sqrt(-1) or sqrt(-1.0) (square root of a negative literal), and any constant-foldable expression that the front-end can statically resolve to a NaN bit pattern. The rule fires on the comparison node, not on the NaN-producing sub-expression in isolation.
See the What it detects section of the rule page for the full pattern definition.
Why it matters
The full GPU-mechanism analysis lives in the Why it matters on a GPU section of the companion rule page.
Examples
The bad / good code snippets are kept canonical on the rule page; see comparison-with-nan-literal.md -> Examples.
See also
- Rule page -- canonical reference + change log.
- misc overview -- broader context.
- ADR 0018 -- v1.0 readiness plan.
This is a v1.0-ship stub. Full analysis pending; track issue link TBD.
TODO: category-overview missing for misc; linked overview is the closest sibling.