4.3.8. __attribute__((pure))

Many functions have no effects except to return a value, and that the 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.

Note

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

Although related, this function attribute is not equivalent to the __pure keyword. The function attribute equivalent to __pure is __attribute__((const)).

Example

int Function_Attributes_pure_0(int b) __attribute__ ((pure));
int Function_Attributes_pure_0(int b)
{
    static int aStatic;
    aStatic++;
    return b++;
}
 
int Function_Attributes_pure_2(int b)
{
    int aLocal=0;
    aLocal += Function_Attributes_pure_0(b);
    return 0;
}

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

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential