<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Apr 12, 2026 at 9:50 PM Dennis via Digitalmars-d-learn <<a href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Saturday, 11 April 2026 at 06:56:36 UTC, Danni Coy wrote:<br>
> ok gets weirder - adding an int to the beginning of the <br>
> anonymous union removes the linker problem.<br>
><br>
> union<br>
> {<br>
> int _;<br>
> EventA a;<br>
> EventB b;<br>
> }<br>
><br>
> Is this a bug, or is there something I am missing?<br>
<br>
Most likely `EventA` has an .init value that isn't all 0. When it <br>
becomes part of a struct or the first member of a union, that <br>
also makes the enclosing struct have a non-zero .init symbol <br>
which you must link when you want to use it. Either make `EventA` <br>
a zero initialized type (you can check with `__traits(isZeroInit, <br>
EventA)`) or override the default init value, like `EventA a = <br>
0;` or `EventA a = void;`.<br>
<br>
Or just ensure that every module you import also gets compiled <br>
into the final executable. Sometimes you can get away with <br>
'header only' imports, but it's bound to bring up subtle issues <br>
like this so it's best to just include everything either using <br>
the `-i` switch or by listing every file yourself.<br></blockquote><div><br></div><div>ok - I tracked down the source of the error, any float is going to be default initialised to NaN, I feel like this should be considered a bug (it makes D look unprofessional) but intialising the floats to zero fixes the issue (as does the other fixes you suggested). </div></div></div>