digitalmars.D - Add -wnan switch to flag default NaN initializations
- Walter Bright (1/1) Aug 20 https://github.com/dlang/dmd/pull/23663
- ABrightLight (2/3) Aug 21 I really like this solution. Thank you Walter
- Walter Bright (3/4) Aug 21 You're welcome. I had the idea when I was out for a jog this morning, an...
- Richard (Rikki) Andrew Cattermole (10/15) Aug 21 I suspect it may be for a similar reason as to why I had not mentioned i...
- Alexandru Ermicioi (3/7) Aug 21 Still a bit better, than nothing right?
- Richard (Rikki) Andrew Cattermole (8/17) Aug 21 Not exactly:
- monkyyy (11/12) Aug 21 Surely its been suggested for years
- claptrap (6/7) Aug 21 I know i've been arguing that zero init is not as much of an
- Kapendev (2/3) Aug 21 Looks good.
- GB (21/22) Aug 22 I think this is a very useful switch because it allows you to
On Friday, 21 August 2026 at 06:26:36 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/23663I really like this solution. Thank you Walter
Aug 21
On 8/21/2026 12:02 AM, ABrightLight wrote:I really like this solution. Thank you WalterYou're welcome. I had the idea when I was out for a jog this morning, and wondered why I hadn't thought of it before.
Aug 21
On 21/08/2026 7:22 PM, Walter Bright wrote:On 8/21/2026 12:02 AM, ABrightLight wrote:I suspect it may be for a similar reason as to why I had not mentioned it. -vtls for instance, is for something quite intractable, it is from symbol resolution. Default initialization, is generally a syntax level feature and is easily seen. They don't serve the same purpose, although they may appear the same on the surface. Also nobody has asked for the ability to audit the locations where this exists, like they did for TLS.I really like this solution. Thank you WalterYou're welcome. I had the idea when I was out for a jog this morning, and wondered why I hadn't thought of it before.
Aug 21
On Friday, 21 August 2026 at 08:03:46 UTC, Richard (Rikki) Andrew Cattermole wrote:They don't serve the same purpose, although they may appear the same on the surface. Also nobody has asked for the ability to audit the locations where this exists, like they did for TLS.Still a bit better, than nothing right?
Aug 21
On 21/08/2026 8:06 PM, Alexandru Ermicioi wrote:On Friday, 21 August 2026 at 08:03:46 UTC, Richard (Rikki) Andrew Cattermole wrote:Not exactly: https://dlang.org/changelog/2.113.0.html#dmd.fastdfa.uninitialized The switch could be useful in tracking down default init, but it won't help you if you write float.nan some place, or is in library code that the compiler isn't seeing. Each of these solutions has their own tradeoffs, and neither is perfect. Its a good feature, but what I have classified as a low value one.They don't serve the same purpose, although they may appear the same on the surface. Also nobody has asked for the ability to audit the locations where this exists, like they did for TLS.Still a bit better, than nothing right?
Aug 21
On Friday, 21 August 2026 at 07:22:29 UTC, Walter Bright wrote:wondered why I hadn't thought of it before.Surely its been suggested for years If your finally convinced its time to resolve the float mess; theres going to be dozens of little details and it should be a package deal. see: https://github.com/dlang/dmd/issues/23666#issuecomment-5372588419 there will be dozens of these if you open the debate in earnest *IF* the goal is to keep float.nan and have a flag that errors out for team 0; fine, but you should define the stable "number-y" api so it becomes tractable to write terse templates https://forum.dlang.org/post/obkghamdrvjibmxrfktg forum.dlang.org
Aug 21
On Friday, 21 August 2026 at 06:26:36 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/23663I know i've been arguing that zero init is not as much of an issue as people think, but Im also aware that it'll never change, too much hassle for little (very subjective) benefit for only some people. So this is a pretty good solution.
Aug 21
On Friday, 21 August 2026 at 06:26:36 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/23663Looks good.
Aug 21
On Friday, 21 August 2026 at 06:26:36 UTC, Walter Bright wrote:https://github.com/dlang/dmd/pull/23663I think this is a very useful switch because it allows you to audit existing code for places where the default value is being relied upon. But it only applies to NaN ?? What is really needed, is a stronger invariant that provides a persistent compile-time state - which is something -wnan cannot do. Two features could however complement each other. -wnan Audit/default-initialization diagnostic "Tell me where the program is relying on default NaN." UNASSIGNED (or perhaps mustAssign since D already has mustUse) Semantic safety contract: "For this variable, default initialization is deliberately not considered sufficient. Prove that an explicit assignment occurred before every read." Useful for new code or particularly important variables. So... fine...keep whatever default initialization Walter wants. Just give programmers a way to say that the default doesn't count as an explicitly established value.
Aug 22









"Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> 