[Joke] C++ and D namings

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 20 15:10:09 UTC 2021


On 1/20/21 9:48 AM, Ola Fosheim Grostad wrote:
> On Wednesday, 20 January 2021 at 14:33:11 UTC, Steven Schveighoffer wrote:
>> But technically, you can set one union member and as long as you don't 
>> use the other, it's never UB. In this case, however, it would seem fine.
>>
>> Your immutable case would ALWAYS be UB, but only if you accessed the 
>> member you didn't set.
> 
> Where does the spec say that unions cannot be used for type punning?
> 
> 

I should say, it's undefined behavior if you ever use the immutable 
value and then mutate the value (just like if you cast it).

-Steve


More information about the Digitalmars-d mailing list