Hacker News new | ask | show | jobs
by theseoafs 3831 days ago
Well, for one, unions have defined behavior in C, while passing pointers around and casting them randomly doesn't.

I don't know if this is the best example. Generally you see unions in C to cover "tagged unions", I.e. Those things that would be subsumed by algebraic data types in other languages.

1 comments

Ah, got it. I am used to C++, where accessing the non-active member of the union is undefined behavior. Thank you.