CTFE Assignment to anonymous union shows unexpected behavior

Rekel paultjeadriaanse at gmail.com
Thu Apr 22 23:44:51 UTC 2021


On Thursday, 22 April 2021 at 23:41:33 UTC, H. S. Teoh wrote:
> 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

I'm not sure what you mean,
do you mean if i were to read the field during CTFE, or even if i 
read the field during runtime after initializing it using CTFE?


More information about the Digitalmars-d-learn mailing list