Skip to content

Comment on Fast Inverse Square Rootparent

Comments

I don't think you can use unions. In the draft of the ISO-IEC 9899 standard (C99) I have, paragraph 6.2.6.1.7 (I'm not kidding) says

> When a value is stored in a member of an object of union type, the bytes of the object representation that do not correspond to that member but do correspond to other members take unspecified values.

So no undefined behaviour (nasal demons and such) but still unspecified.

I suppose this is saying something like this

union X{ char a; float b; }

If you store something in a, the other 3 bytes corresponding to b are unspecified

But I suspect this doesn't apply if a and b have the same size.

This was corrected in C99.TC2 with the addition of footnote 82 (footnote 95 in C11).

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.