Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: lvalue types Date: Mon, 02 Apr 2018 15:19:35 -0700 Organization: None to speak of Lines: 48 Message-ID: References: <2b687d74-f559-43a9-9aec-8a1067467ce2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="59c91fcd0d5933af9c9624494db21dc4"; logging-data="10528"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19K3I4f3GyltxjCtEcgZEFV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:25wqIV145vcPDhZaI8ZVcqSpNio= sha1:IMY3hy/c6DdpkRBdNmTz7Qf62Is= Xref: csiph.com comp.lang.c:128647 Keith Thompson writes: [...] > Given this program: > > #include > int main(void) { > struct s { int m; }; > struct s obj = { 0 }; > obj.m = 42; > printf("%d\n", obj.m); > } > > Does the assignment `obj.m = 42;` modify the value of the object `obj.m`? > Does the assignment `obj.m = 42;` modify the value of the object `obj`? > (The phrase "modify the value of [the] object" is from the standard's > definition of "access".) [...] I thought for a while that there might be something that would resolve the oversight I saw in 6.5p7. In the assignment expression obj.m = 42 there are two lvalues, `obj` and `obj.m`. One could argue that obj is accessed by the value `obj`, which is of type `struct s`. But on further thought, that doesn't resolve it: struct s { int m; }; struct s obj = { 0 }; int *ptr = &obj.m; *ptr = 42; In this assignment, there is no lvalue of type `struct s`, but the object `obj` of type `struct s` is modified. Oh well. (I remain convinced that both obj.m and obj are accessed/modified by the assignment.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"