stefan@xxxxxxxxx writes: > Am 4. Dezember 2020 00:00:28 MEZ schrieb Andrea Corallo via Gcc-help <gcc-help@xxxxxxxxxxx>: >>David Brown <david.brown@xxxxxxxxxxxx> writes: >> >>Hi David, >> >>> As "f()" runs, the value of "y->fun_ptr" changes with each step as >>you >>> get alternating "foo1", "foo2" outputs. Thus it is clear (I hope) >>that >>> the compiler cannot assume that "y->fun_ptr" is not clobbered by the >>> function call. >> >>Indeed that's clear. The question is more if there's some way to >>express >>this to the compiler qualifying the variables in discussion without >>changing the structure of the code. This because as I wrote may be not >>trivial to modify the code generator for optimal results. >> >>I understand this is probably not possible and there's no magic >>attribute or qualifier to express this. >> >>Thanks >> >> Andrea > > IMHO it's a bug that const members referenced by a const pointer are reloaded inside the loop. I might open a bug but my understanding is that const is generally not used for optimizations. Am I wrong? Andrea