float init 0 request
Indraj Gandham
newsgroups at indraj.net
Fri Aug 14 12:48:50 UTC 2026
On Friday, 14 August 2026 at 10:42:16 UTC, Alexandru Ermicioi
wrote:
> On Friday, 14 August 2026 at 08:09:45 UTC, Jonathan M Davis
> wrote:
>> The language relies on the ability to default-initialize
>> objects. For instance, that's what happens when you allocate a
>> dynamic array or increase its length. There has to be a
>> default value for that to work. It's part of why adding the
>> ability to disable default initialization for structs has been
>> a mess. It's arguably necessary for some contexts, but it
>> means that those structs can't legally be used in any context
>> where default initialization is required. Doing the same to
>> floating point types would be even worse given that they're a
>> built-in type rather than something specific to a particular
>> code base.
>
> Right, that would cause mayhem in templated code, an extra
> static if at minimum.
This is a valid point, but it merely implies that there should be
a default initialisation value. It does not imply that this value
must be NaN. It's worth noting that the proposed change was
implemented in OpenD and there have been very few complaints. If
correctness is the goal, the way forward is static analysis, not
an "error" value which doesn't actually trigger any sort of error
handling or exception.
More information about the Digitalmars-d
mailing list