Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #128647

Re: lvalue types

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: lvalue types
Date 2018-04-02 15:19 -0700
Organization None to speak of
Message-ID <lnlge5s13c.fsf@kst-u.example.com> (permalink)
References (7 earlier) <lnin9rrj8u.fsf@kst-u.example.com> <kfno9jam2zw.fsf@x-alumni2.alumni.caltech.edu> <ln370lwl52.fsf@kst-u.example.com> <kfnd0zllgtf.fsf@x-alumni2.alumni.caltech.edu> <lnmuypttsx.fsf@kst-u.example.com>

Show all headers | View raw


Keith Thompson <kst-u@mib.org> writes:
[...]
> Given this program:
>
> #include <stdio.h>
> 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  <http://www.ghoti.net/~kst>
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"

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: lvalue types Tim Rentsch <txr@alumni.caltech.edu> - 2018-03-26 23:44 -0700
  Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-03-27 09:14 -0700
    Re: lvalue types supercat@casperkitty.com - 2018-03-27 12:21 -0700
      Re: lvalue types Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-28 17:01 -0700
      Re: lvalue types Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-29 01:54 -0700
    Re: lvalue types Tim Rentsch <txr@alumni.caltech.edu> - 2018-03-30 08:32 -0700
      Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-03-30 09:25 -0700
        Re: lvalue types jameskuyper@verizon.net - 2018-03-30 10:58 -0700
        Re: lvalue types Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-31 00:52 -0700
        Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-04-02 15:19 -0700
          Re: lvalue types supercat@casperkitty.com - 2018-04-03 10:06 -0700
            Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-04-03 11:33 -0700
              Re: lvalue types supercat@casperkitty.com - 2018-04-03 12:19 -0700
                Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-04-03 12:48 -0700
              Re: lvalue types supercat@casperkitty.com - 2018-04-05 10:17 -0700
                Re: lvalue types Keith Thompson <kst-u@mib.org> - 2018-04-05 10:52 -0700
                Re: lvalue types supercat@casperkitty.com - 2018-04-05 12:39 -0700
                Re: lvalue types Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-06 06:13 -0700
        Re: lvalue types Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-04 16:38 -0700
  Re: lvalue types supercat@casperkitty.com - 2018-03-27 12:09 -0700
    Re: lvalue types Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-28 10:48 -0700

csiph-web