Liste des Groupes | Revenir à cl c |
Whether we can or cannot predict the values of `(pa==pc)` and `(pb==pc)` has very little impact on the usability of such expressions. The practical usability of such expressions is very high without relying on `(pa==pc)` and `(pb==pc)`.>It's only not UB in the nazal demons sense.
Here's a version of the same code that corrects the above distracting
issues
>
#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.
>
It's UB in a sense that we can't predict values of expressions
like (pa==pc) and (pb==pc). I.e. pc is completely useless. In my book
it is form of UB.
Les messages affichés proviennent d'usenet.