float init 0 request
user1234
user1234 at 12.de
Mon Aug 17 12:47:56 UTC 2026
On Monday, 17 August 2026 at 07:47:09 UTC, pete wrote:
> There is something I don't understand here. If an uninitialised
> float is an error then why does the compiler not just raise it
> at compile time rather than setting it to a value that is
> always wrong and letting someone *hopefully* find it at runtime?
> [...]
My understanding is that this would require complex static
analysis which is somewhat possible (DFA) put not entirely due to
call to extern C functions, or even D functions but linked using
a separate compilation mode:
```d
extern(C) void v(ref float);
void f()
{
float f; // so init with NaN
v(f); // what `v` will do on `f` is not known
}
```
That being said, I'm on the zero-init camp too.
More information about the Digitalmars-d
mailing list