float init 0 request
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Fri Aug 14 13:54:22 UTC 2026
On 14/08/2026 10:42 PM, Alexandru Ermicioi wrote:
> Also, languages like Java where they make it illegal to use a
> variable before you give it a value show how problematic it can be
> to make it an error to not explicitly initialize a variable, because
> it's pretty easy to get into situations where you know for sure that
> the variable is given a value before it's used, but the compiler
> isn't smart enough to figure that out, so you're forced to give it a
> dummy value just to shut it up.
>
> Nowadays java compiler seems smarter, it doesn't force you initialize it
> at declaration site, if all branches after declaration get var
> initialized before its use.
This only works without false positives in limited cases.
The moment pointers are involved, loops, or functions it basically error
central.
The fast dfa engine has to ignore any variable that is in a closure
context specifically because it can't be modeled.
Which is a bit of a problem for us, see unreachable code error for why
it isn't a good by default bit of analysis.
More information about the Digitalmars-d
mailing list