CTFE Assignment to anonymous union shows unexpected behavior
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Apr 22 23:41:33 UTC 2021
On Thu, Apr 22, 2021 at 10:47:17PM +0000, Rekel via Digitalmars-d-learn wrote:
> I'm not sure why this is happening, but after simplifying my code I
> traced it back to what the title may suggest.
Keep in mind that CTFE does not support reinterpretation via unions,
i.e., reading values from a different field in a union than was
assigned. If you assign field A to a union, then you cannot read field B
from that union in CTFE. You can only do this at runtime, not in CTFE.
T
--
There are two ways to write error-free programs; only the third one works.
More information about the Digitalmars-d-learn
mailing list