Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C gore of the weak

Name: Anonymous 2009-09-11 17:52

1. Does this operation invoke undefined behavior?

union {
  int i;
  struct {
    int i1;
    int i2;
  } s;
} u;

u.i = 3;
printf("%d\n", u.s.i1);

Name: Anonymous 2009-09-12 0:00

I think compilers should reorder structs in reverse member size order (largest members first) to minimize padding waste. Elements with the same size would be placed in declaration order. What could possibly go wrong with such a scheme? It wouldn't affect >>1 but it might break more unorthodox uses (which I'm sure are undefined behavior to begin with).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List