Liste des Groupes | Revenir à cl c |
It is going to cause problems, if the code relies on the address identity of the object, assuming the standard intends to provide such guarantees.>You snipped this: "Any attempt to modify an object with temporary
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.
lifetime results in undefined behavior.". Which means, I think,
that an implementation that shared storage for "such an object"
with something else probably isn't going to cause problems for any
code with defined behavior.
Though I can imagine the possibility of code that modifies `a` andThat's easy (in the context of declarations from my previous example):
reads via `pc` within the same full expression.
But unless I've somehow missed it, the "Such an object need notIf so, that would be extremely underspecified. A mere "such an object need not have a unique address" is insufficient to fully convey the permission to overlap existing named objects. And that's probably what led to difference in interpretation between GCC and Clang.
have a unique address." wording doesn't appear on that web page or
in my copy of n1570.pdf. C17 does add these two sentences:
An object with temporary lifetime behaves as if it were declared
with the type of its value for the purposes of effective type. Such
an object need not have a unique address.
Normally any two objects with overlapping lifetime must have distinct
addresses. This addition, I think, gives compilers permission to have
temporary lifetime objects overlap with other existing objects, but not
to have a modification to one object affect the value of the other
(unless the modification invokes UB, of course).
Les messages affichés proviennent d'usenet.