]> granicus.if.org Git - nethack/commit
union bit (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 11 Jul 2006 04:08:24 +0000 (04:08 +0000)
committernethack.rankin <nethack.rankin>
Tue, 11 Jul 2006 04:08:24 +0000 (04:08 +0000)
commit65e12e036264faa2872b1dba426dbc7b1fad7dd8
tree45481d44b457f92c082fcb7b851f69b6db611442
parent0abece54c1587186d65b536bce70f9a5a7e2c219
union bit (trunk only)

     I'm pretty sure that some pre-standard compilers don't know how to
apply an initializer to a variable of type union.  Unfortunately, I don't
have access to one to check.  Fortunately, there's no need to explicitly
initialize `zeroany' since the default value is what we want--the first
field will be set to zero or null as appropriate (null in this case).

     Strictly speaking, this isn't adequate; what if long is wider than a
pointer rather than narrower?  Using `= {DUMMY}' didn't handle that case
either; the ordering of the union's fields controls which bits get stored.
As a practical matter, it should make no difference.  As long as the code
reading a union accesses the same field as the code writing that union set
up in it, anything in extraneous bits should be irrelevant--except perhaps
when a debugger tries to format things.  The whole issue has always been
implicitly based on the assumption that null pointers have all bits zero
in the first place; that's typical but not guaranteed.
src/decl.c
src/hack.c