float init 0 request

Dukc ajieskola at gmail.com
Mon Aug 17 16:55:18 UTC 2026


On Friday, 14 August 2026 at 05:57:55 UTC, ABrightLight wrote:
> 2. It is argued that since, like pointers that have `null` and 
> are default initialized to this, floats should also initialize 
> to its version of `null`. However this is a false equivalence 
> since the use of a null pointer is specified/standardized to 
> crash the program due to a concern for memory safety (it's not 
> even set to undefined behavior, a program halt must occur). The 
> same memory safety concern is not present for most operations 
> relying on floats, and the existence of NaN being left without 
> a crash [or even an exception thrown] is to cater to 
> performance.

I don't think so. Using NaN will result in another NaN, so 
eventually the error will show up, unless you end up discarding 
the value and not using it anyhow. Just as good as aborting 
immediately.

Well, except for casts and comparison operators. IMO there should 
be an error if you try to compare a NaN to anything or cast it to 
an integer. Currently those cases are what lead to silent 
failures.



More information about the Digitalmars-d mailing list