On 03/10/2015 05:44 PM, Robbert Krebbers wrote:
On 03/10/2015 05:18 PM, Martin Sebor wrote:
I suspect every compiler relies on this requirement in certain
cases otherwise copying would require making use of temporary
storage. Here's an example:
Thanks, this example is indeed not already undefined by effective types,
nor 6.2.6.1p6.
Now to make it more subtle. As far as I understand 6.5.16.1p3, undefined
behavior can already occur without the use of union types or malloc. For
example:
struct S { int x, y; };
int main() {
struct S p = (struct S){ .x = 10, .y = 12 };
p = (struct S){ .x = p.x, .y = 13 };
return p.x;
}
is undefined AFAIK.
Is anyone aware of an example program that does not use unions or
malloc, but where GCC performs optimizations justified by only
6.5.16.1p3 of C11?