fork(3) download
  1. // gcc -fstrict-aliasing -std=c99 -O2
  2. union
  3. {
  4. int i;
  5. short s;
  6. } u;
  7.  
  8. int * i = &u.i;
  9. short * s = &u.s;
  10.  
  11. int main()
  12. {
  13. *i = 2;
  14. *s = 100;
  15.  
  16. printf(" *i = %d\n", *i); // prints 2
  17. printf("u.i = %d\n", u.i); // prints 100
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
 *i = 2
u.i = 100