Sujet : Re: Regarding assignment to struct
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 06. May 2025, 01:53:14
Autres entêtes
Organisation : None to speak of
Message-ID : <87r012ftl1.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Gnus/5.13 (Gnus v5.13)
Tim Rentsch <
tr.17687@z991.linuxsc.com> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
Andrey Tarasevich <noone@noone.net> writes:
[...]
>
#include <stdio.h>
>
struct S { int a[10]; };
>
int main()
{
struct S a, b = { 0 };
int *pa, *pb, *pc;
>
pa = &a.a[5],
pb = &b.a[5],
pc = &(a = b).a[5],
printf("%p %p %p\n", (void *) pa, (void *) pb, (void *) pc);
}
>
This version has no UB.
>
I believe it does. [...]
>
If you look again carefully, I expect you will reach a
different conclusion.
Please explain. Or don't.
I explained, in text that you snipped, why I think it has UB.
If there's a flaw in my reasoning, I invite you to point it out
without being mysterious.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */