SC22/WG14/N759 Changes adopted by WG14 Minor issue with Compound Literals ================================== Clive Feather clive@demon.net 1997-09-18 Note ==== It was decided that independent changes to 6.1.2.4 had resolved the basic issue. Proposal ======== Add a new example to Compound Literals (currently 6.3.2.6): Example: Each compound literal creates only a single object in a given scope: struct s { int i; }; int f (void) { struct s *p = 0, *q; int j; for (j = 0; j < 2; j++) q = p, p = &((struct s){ j }); return p == q && q.i == 1; } The function f() always returns the value 1. Note that if the body of the for loop were enclosed in braces, the lifetime of the unnamed object would be the body of the loop only, and on entry next time round p would be pointing to an object which is no longer guaranteed to exist, which is undefined behaviour.