automatic NaN propogation detection?
Elronnd
elronnd at elronnd.net
Sat Sep 25 08:18:49 UTC 2021
On Saturday, 25 September 2021 at 07:53:11 UTC, Chris Katko wrote:
> Is that some sort of "NP complete" can't-fix issue or something?
The general case is obviously unsolvable. Trivial proof: float x
= nan; if (undecidable) use x. I'm sure your imagination can
supply more realistic cases (but I promise they really do come
up!)
However that doesn't mean we can't do flow analysis
conservatively. Similar caveats apply to @live, but that does
not mean it is useless. (Not saying @live isn't useless, just
that this doesn't indicate that.) The bigger problem is that it
really is hard to tell if you 'meant' to use a nan somewhere or
not.
And if you tried to apply such a semantic analysis pass to
existing code, you would find it riddled with false positives,
where a float was default-initialized to nan and the compiler was
unable to convince itself the variable was overridden before
being used in all paths.
More information about the Digitalmars-d-learn
mailing list