Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #161943
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Array is an non-modifiable lvalue - where does it matter? |
| Date | 2021-07-16 15:22 -0700 |
| Organization | None to speak of |
| Message-ID | <875yx93nnb.fsf@nosuchdomain.example.com> (permalink) |
| References | <scq5c5$tql$1@dont-email.me> <scsiq3$ens$1@dont-email.me> |
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 7/15/21 4:21 PM, Andrey Tarasevich wrote:
>> 6.3.2/1 says that
>>
>> 1 [...] A modifiable lvalue is an lvalue that does not have array
>> type, [...]
>>
>> Based on that, arrays are non-modifiable lvalues. We all know what it
>> actually means. But is there any context in the standard in which this
>> non-modifiability of array lvalues would actually _matter_, would
>> actually interact with some other standard requirement?
>>
>> One thing that comes to mind is a constraint on assignment operators
>> (6.5.16/2)
>>
>> 2 An assignment operator shall have a modifiable lvalue as its left
>> operand.
>>
>> So, one can combine 6.3.2/1 and 6.5.16/2 and conclude that one can't
>> assign to arrays. But I believe that constraints are intended/supposed
>> to be applied after automatic implicit conversions. And since LHS of
>> assignment is not one of the contexts excluded from array type decay,
>> said decay is already sufficient to prevent assignment to arrays.
>
> The Rationale says "the fact that a[i] is a modifiable lvalue while a is
> not has puzzled many students of the language. A more precise
> description was incorporated in C89 in the hope of combatting this
> confusion."
>
> I have a vague memory that this wording is connected to a subtle issue
> with functions that return values of struct type, where the struct
> contains an array member. But I can't remember what the issue was.
I think that case is separate from what we're discussing here, though of
course they're both related to the odd way C treats array expressions.
This thread is about lvalues that are of array type.
The struct return issue is about expressions of array type that are not
lvalues (something that's no longer possible as of C11, I think).
In C90 and C99, if a function returns a struct with a member of array
type and you refer to the name of that member:
func().array_member
then that's an expression of array type which is converted (in most
contexts) to a pointer to the initial element of "the array object".
The problem: In that specific case there is no array object (a function
call yields a value, not an object). C11 resolved that by inventing an
object with "temporary lifetime". There are cases other than function
calls where this shows up; the assignment, comma, and conditional
operators can yield non-lvalues of struct type.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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