https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85205
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Mijzelf from comment #0) > args.data[ i ].var1 = i; This is undefined behaviour when i>0 because the array only has one element. It's irrelevant that the union has additional space, the array doesn't. > If the code is changed so data has 0 elements: > > struct X{ > int length; > > struct Y { > int var1; > int var2; > } data[ 0 ]; > }; > > the code works as expected This works due to a GNU extension: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html#Zero-Length