Liste des Groupes | Revenir à cl c |
On Mon, 5 May 2025 01:29:47 -0700No, it isn't.
Andrey Tarasevich <noone@noone.net> wrote:
On Mon 5/5/2025 1:12 AM, Michael S wrote:>>
According to my understanding, you are wrong.
Taking pointer of non-lvalue is UB, so anything compiler does is
conforming.
Er... What? What specifically do you mean by "taking pointers"?
>
The whole functionality of `[]` operator in C is based on pointers.
This expression
>
(a = b).a[5]
>is already doing your "taking pointers of non-lvalue" (if IThat is not UB:
understood you correctly) as part of array-to-pointer conversion. And
no, it is not UB.
>
This is not UB either
>
struct S foo(void) { return (struct S) { 1, 2, 3 }; }
...
int *p;
p = &foo().a[2], printf("%d\n", *p);
>
int a5 = (a = b).a[5];
That is UB:
int* pa5 = &(a = b).a[5];
If you read the post of Keith Thompson and it is still not clears toThe only valid "UB" claim in Keith's post is my printing the value of `pc` pointer, which by that time happens to point nowhere, since the lifetime of the temporary is over. (And, of course, lack of conversion to `void *` is an issue).
you then I can not help.
Les messages affichés proviennent d'usenet.