Tell GCC functions do not modify struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Everyone,

I'm playing with GCC optimization and come up with a quite common scenario:

struct A { int a; };

void print_a(const struct A *);

int test() {
    const struct A a = {3};
    print_a(&a);
    return a.a == 3;
}

GCC always products a load operation of a.a, that's reasonable. But my
question is, how to tell GCC that the function is guaranteed to not
modify the struct?

I've tried `access` attribute, but that does not help. Of course I can
use __builtin_unreachable around the function call to make a promise,
but that is not a struct-independent solution.

Thanks



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux