@safe accessing of union members

Dominikus Dittes Scherkl dominikus at scherkl.de
Thu Mar 18 07:55:10 UTC 2021


On Wednesday, 17 March 2021 at 19:09:18 UTC, ag0aep6g wrote:
> In anticipate him addressing issue by defining 0 = false, 
> anything else = true. Then all bit patterns are safe, and it's 
> just a matter of fixing code that expects only 0 or 1.
There is another interpretation that would make all patterns safe:

lowest bit is 0 = false, lowest bit is 1 = true.

This has the advantage that any garbage in higher bits doesn't 
invalidate the bool.
But of course, even values beeing considered "false" may feel 
somewhat strange...


More information about the Digitalmars-d mailing list