Liste des Groupes | Revenir à cl c |
Bart <bc@freeuk.com> writes:This is always valid, when compiling this translation unit. If 'p' is defined wrongly elsewhere, then that's outside the remit of the compiler.
On 02/09/2024 13:03, Ben Bacarisse wrote:I wonder what it was you were really objecting to in the original remarkKaz Kylheku <643-408-1753@kylheku.com> writes:>
>On 2024-08-29, Ben Bacarisse <ben@bsb.me.uk> wrote:...Your intervention derailed the discussion into one of syntax. Bart thenDo you think (or claim) that what is /required/ on each side of an>
assignment in C is exactly the same thing? The expression on the LHS is
required to be a modifiable lvalue expression. That does not apply to
the expression on right hand side.
"modifiable lvalue" is a semantic attribute which depends on type
and qualification. An array is an lvalue, but not modifiable.
A const-qualified expression is also not a modififiable lvalue.
>
Bart is insisting that these attributes are not a matter of syntax.
simply stopped talking about his original claim. Way back I pointed
out that:
|| What is needed on the two sides is not the same.
And he replied
| I would argue that it is exactly the same.
He did, later, say that is was "exactly the same" except for the
differences but then went back to "I do mean exactly the same".
>
I said this:
>I explained that. LHS and RHS can be identical terms for assignment in>
pretty much every aspect, but there are extra constraints on the LHS.
You then sarcastically suggested:
>So you use "exactly the same" to mean "exactly the same except for the>
differences".
I then clarified:
>No, I do mean exactly the same, both in terms of syntax and (in my
implementations, which are likely typical) internal representation of
those terms.
...So are no differences when considering only valid programs.
that I made. Since ignoring the differences in what is required on the
LHS and RHS all result in invalid programs your summary is (to a first
approximation) correct, but it does not render mine wrong in any
interesting way.
I note that you have, again, indulged in strategic snipping. The "..."
was "There are no differences other than where the type system says your
code is invalid.". What is it about the type system of C that makes
int main(void) {
extern char *p;
*p = 0;
}
invalid? Because sometimes it is,
depending on what p is in some otherFew of the compilers I tried reported a syntax error.
translation unit. Are you using your own meaning for "type system"? If
so what is it?
And as for your remarks about typical implementations, does your C
parser /really/ accept an assignment expression on both sides of an =
operator? What does that even look like in the code? I have written
one C parser, contributed to one other and (over the years) examined at
least two more, and none of them do what you seem to be suggesting is
typical.
Les messages affichés proviennent d'usenet.