I've noticed a heavy use of the restrict
keyword in one of our legacy projects.
I understand the rationale for restrict
, but I question its useful-ness when applied to some of these functions.
Take the following two examples:
void funcA(int *restrict i){
// ...
}
void funcB(int *restrict i, float *restrict f){
// ...
}
int main(){
int i = 1;
float f = 3.14;
funcA(&i);
funcB(&i,&f);
}
Is there any valid reason one might tag the parameters of funcA
and funcB
with restrict
?
funcA
only takes 1 parameter. How could it have the same address as anything else?
funcB
takes parameters of different types. If they were the same address, wouldn't that already be breaking the strict aliasing rule?