You copied the Doc URL to your clipboard.

3.10 __attribute__((pure)) function attribute

Many functions have no effects except to return a value, and their return value depends only on the parameters and global variables. Functions of this kind can be subject to data flow analysis and might be eliminated.


This function attribute is a GNU compiler extension that the ARM compiler supports.


int bar(int b) __attribute__((pure));
int bar(int b)
    return b++;
int foo(int b)
    int aLocal=0;
    aLocal += bar(b);
    aLocal += bar(b);
    return 0;

The call to bar in this example might be eliminated because its result is not used.

Related reference