Liste des Groupes | Revenir à cl c |
On Sun 5/4/2025 6:48 AM, Tim Rentsch wrote:>One dark corner this feature has, is that in C (as opposed to C++) theI'm curious to know what interesting consequences you mean here. Do
result of an assignment operator is an rvalue, which can easily lead
to some interesting consequences related to structs with arrays
inside.
you mean something other than cases that have undefined behavior?
I'm referring to the matter of the address identity of the resultant
rvalue object. At first, "address identity of rvalue" might sound
strange, but the standard says that there's indeed an object tied to
such rvalue, and once we start applying array-to-pointer conversion
(and use `[]` operator), lvalues and addresses quickly come into the
picture.
>
The standard says in 6.2.4/8:
>
"A non-lvalue expression with structure or union type, where the
structure or union contains a member with array type [...]
refers to an object with automatic storage duration and temporary
lifetime. Its lifetime begins when the expression is evaluated and its
initial value is the value of the expression. Its lifetime ends when
the evaluation of the containing full expression ends. [...] Such an
object need not have a unique address."
https://port70.net/~nsz/c/c11/n1570.html#6.2.4p8
>
I wondering what the last sentence is intended to mean ("... need not
have a unique address"). At the first sight, the intent seems to be
obvious: it simply says that such temporary objects might repeatedly
appear (and disappear) at the same location in storage, which is a
natural thing to expect.
Les messages affichés proviennent d'usenet.