Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #161952
| 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-17 14:01 -0700 |
| Organization | None to speak of |
| Message-ID | <871r7w3b9e.fsf@nosuchdomain.example.com> (permalink) |
| References | <scq5c5$tql$1@dont-email.me> <20210716145835.570@kylheku.com> <sctt7r$88g$1@dont-email.me> <20210717094529.447@kylheku.com> |
Kaz Kylheku <563-365-8930@kylheku.com> writes:
> On 2021-07-17, Andrey Tarasevich <andreytarasevich@hotmail.com> wrote:
>> On 7/16/2021 3:21 PM, Kaz Kylheku wrote:
>>> If what you are getting at is this: could a C dialect provide complete
>>> support for array passing, returning and assignment, while conforming
>>> to the current standard?
>>>
>>> The answer is no.
>>
>> No, no, no, I'm not interested in that at all.
>>
>>>> Am I right here? Is the constraint of 6.5.16/2 supposed to be applied
>>>> before automatic implicit conversions or after them?
>>>
>>> It looks moot. Before conversion to pointer, you have an array lvalue,
>>> and the requirement says that it' not modifiable. Thus, cannot assign to
>>> it. After conversion to pointer, you don't have an lvalue. Not
>>> assignable, either.
>>>
>>
>> Yes, it is moot for the specific case of arrays.
>>
>> But at the same time it intuitively looks and feels like a more general
>> issue. Again, what comes first: automatic implicit conversions or
>> constraint checks?
>
> In "array = foo", there is no implicit conversion of array. It is
> an lvalue of array type and remains that way.
I don't believe that's correct. `array` is an expression of array type
(whether it's an lvalue or not). The standard specifies three contexts
in which such an expression is not converted a pointer expression (N1570
lists 4, but it's incorrect). The LHS of an assignment is not one of
those contexts.
If the conversion did not apply, the assignment would be a constraint
violation because `array` is not a *modifiable* lvalue. But the
conversion does apply, and so the assignment is a constraint violation
because, after the conversion, `array` is a non-lvalue expression of
pointer type.
Of course it doesn't matter *why* it's a constraint violation, as long
as the implementation issues a diagnostic.
> If the assignment were allowed, then how it would likely work is
> that the "array = foo" expression, as a whole would implicitly convert
> to a pointer but not "array" itself.
>
> This is analogous to i = j = 0, j is an lvalue and stays that way.
> However (j = 0) isn't an lvalue.
--
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