[Bug tree-optimization/58806] New attribute for functions that access memory only through their arguments

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Oct 21 02:14:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58806

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
struct A { int i; double d; };

void g(double*);
void f(){
  A a;
  a.i=1;
  g(&a.d);
  if(a.i != 1) __builtin_abort();
}

Here, I guess g is allowed to take its argument, cast it to char*, subtract
offsetof(struct A, d), cast to A* and go modify ->i of that? It would be
convenient to have a way to promise that g does no such thing, but that looks
like a different type of promise than the one in comment #0.

The example is derived from the use of a temporary object of a
reference-counted type, where ideally all uses of the counter should disappear
and the code be equivalent to: double d; g(&d);



More information about the Gcc-bugs mailing list