Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail From: jgk@panix.com (Joe keane) Newsgroups: comp.std.c Subject: Re: Description of "." operator Date: Sun, 9 Dec 2012 23:34:06 +0000 (UTC) Organization: Public Access Networks Corp. Lines: 37 Message-ID: References: NNTP-Posting-Host: panix5.panix.com X-Trace: reader1.panix.com 1355096046 15238 166.84.1.5 (9 Dec 2012 23:34:06 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 9 Dec 2012 23:34:06 +0000 (UTC) X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Xref: csiph.com comp.std.c:1736 In article , Keith Thompson wrote: >N1570 6.5.2.3p3 says: > > A postfix expression followed by the . operator and an identifier > designates a member of a structure or union object. The value > is that of the named member, and is an lvalue if the first > expression is an lvalue. > >Consider the use of the word "object" in the first sentence. > >An expression of struct type doesn't necessarily refer to an *object* of >that type. Look up 'temporary lifetime' (6.2.4). >For example: > > struct pair { int x; int y; }; > struct pair func(void) { > struct pair result = { 10, 20 }; > return result; > } > ... > int y = func().y; Change your code to: struct pair { int x; int y; char thisisbs[1]; }; struct pair func(void) { struct pair result = { 10, 20 }; return result; } ... int y = func().y; to make it work.