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


Groups > comp.lang.c > #161946

Re: Array is an non-modifiable lvalue - where does it matter?

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Array is an non-modifiable lvalue - where does it matter?
Date 2021-07-17 16:23 +0200
Organization A noiseless patient Spider
Message-ID <scup4s$498$1@dont-email.me> (permalink)
References (1 earlier) <5c1d96ea-c554-4aa1-b0db-a7729027ee04n@googlegroups.com> <875yxbth6r.fsf@bsb.me.uk> <e6132d4c-d915-492a-a76e-2d4a2062d353n@googlegroups.com> <scrdrf$g4r$1@dont-email.me> <scshd7$r7p$1@dont-email.me>

Show all headers | View raw


On 16/07/2021 19:59, Andrey Tarasevich wrote:
> On 7/16/2021 12:52 AM, David Brown wrote:
>>
>> The standard says "A modifiable lvalue is an lvalue that does not have
>> array type".  When applied to "a = b", this has been interpreted to mean
>> that "a" is an lvalue of array type and therefore a non-modifiable
>> lvalue, so you cannot use the assignment.  This is, AFAICS, subtly
>> incorrect - used here, "a" is converted to a non-lvalue pointer to its
>> first element.  It is not an lvalue at all, modifiable or non-modifiable.
>>
> 
> That's actually part of the question I was asking originally.
> 
> You are implicitly insisting that the array-to-pointer conversion should
> be applied first, and only after that the constraints of the assignment
> operator should be checked.
> 

I'm not sure I'd use the word "insisting", but that is correct.

> Can you provide a reference to C standard that would indicate that it is
> supposed to be done in that specific order, and not the other way around?

Assignment is an operator, and thus the left-hand side is an expression.
 6.3.2.1p3 says:

"""
Except when it is the operand of the sizeof operator, or the unary &
operator, or is a string literal used to initalize an array, an
expression that has type "array of type" is converted to an expression
with type "pointer to type" that points to the initial element of the
array object and is not an lvalue.
"""

As for the order in which the conversions are done here, I think these
come from the grammar of the language - subexpressions must be converted
before the operand using them.  I can't conceive of how a language could
do anything else here, but it is given in 6.5p1 anyway.  (Generated code
can do calculations in any order as long as the results are correct.)

> 
> For example, C++ standard is known to use wording like "this (conversion
> | transformation | adjustment) is applied before and further (analysis |
> consideration) is performed" in order to eliminate such ambiguities.
> 

Yes, but that is because in C++ you can have many implicit conversions
and thus the ordering is not clear.

> But I don't see anything like that in C standard. One can argue that it
> doesn't matter since the outcome is functionally the same either way.
> But still... the question is intended as a "language-lawyer" one.
> 

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


Thread

Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-15 13:21 -0700
  Re: Array is an non-modifiable lvalue - where does it matter? Öö Tiib <ootiib@hot.ee> - 2021-07-15 13:55 -0700
    Re: Array is an non-modifiable lvalue - where does it matter? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-07-15 22:12 +0100
      Re: Array is an non-modifiable lvalue - where does it matter? Öö Tiib <ootiib@hot.ee> - 2021-07-15 15:07 -0700
        Re: Array is an non-modifiable lvalue - where does it matter? David Brown <david.brown@hesbynett.no> - 2021-07-16 09:52 +0200
          Re: Array is an non-modifiable lvalue - where does it matter? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-16 02:31 -0700
          Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-16 10:59 -0700
            Re: Array is an non-modifiable lvalue - where does it matter? David Brown <david.brown@hesbynett.no> - 2021-07-17 16:23 +0200
              Re: Array is an non-modifiable lvalue - where does it matter? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-07-17 20:14 -0400
    Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-15 14:36 -0700
      Re: Array is an non-modifiable lvalue - where does it matter? Öö Tiib <ootiib@hot.ee> - 2021-07-15 15:19 -0700
  Re: Array is an non-modifiable lvalue - where does it matter? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-15 14:06 -0700
  Re: Array is an non-modifiable lvalue - where does it matter? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-07-16 14:22 -0400
    Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-16 11:43 -0700
      Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-17 18:24 -0700
        Re: Array is an non-modifiable lvalue - where does it matter? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-17 20:29 -0700
        Re: Array is an non-modifiable lvalue - where does it matter? Siri Cruise <chine.bleu@yahoo.com> - 2021-07-17 21:25 -0700
    Re: Array is an non-modifiable lvalue - where does it matter? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-16 15:22 -0700
  Re: Array is an non-modifiable lvalue - where does it matter? Kaz Kylheku <563-365-8930@kylheku.com> - 2021-07-16 22:21 +0000
    Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-16 23:27 -0700
      Re: Array is an non-modifiable lvalue - where does it matter? Kaz Kylheku <563-365-8930@kylheku.com> - 2021-07-17 16:53 +0000
        Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-17 10:49 -0700
        Re: Array is an non-modifiable lvalue - where does it matter? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-17 14:01 -0700
      Re: Array is an non-modifiable lvalue - where does it matter? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-07-18 02:09 +0100
    Re: Array is an non-modifiable lvalue - where does it matter? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-07-17 20:12 -0400
  Re: Array is an non-modifiable lvalue - where does it matter? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-07-17 13:20 -0700
    Re: Array is an non-modifiable lvalue - where does it matter? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-19 14:44 -0700
      Re: Array is an non-modifiable lvalue - where does it matter? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-07-23 23:26 -0700

csiph-web