Hi Richard,

I noticed that GCC 11 has different behavior in the following
example relative to 10.2 with -O2. I wonder whether this
is an intentional change and if yes, what are the rules?

Thanks!
Martin

https://godbolt.org/z/57res7ax1

#include <stdio.h>
#include <stdlib.h>


__attribute__((__noinline__, __weak__))
void f(long unk, void *pa, void *pa2, void *pb, long *x) {
  for (long i = 0; i < unk; ++i) {
    int oldy = *(int *)pa;
    *(float *)pb = 42;
    *(int *)pa2 = oldy ^ x[i];
  }
}

int main(void) {
  void *p = malloc(sizeof(int));
  *(int *)p = 13;
  f(1, p, p, p, (long []){ 0 });
  printf("*pa(%d)\n", *(int *)p);
}

Reply via email to