xaxa
xaxa

Reputation: 1159

keyword/compiler option in C to promise not to overlap different pointers

Is there a keyword/compiler option in modern standards of C language which tells the compiler that I promise not to overlap different pointer-variables in memory? Say,

void f(int *x, int *y);

promise that my manipulations with x will not implicitly affect y. E.g. x and y are arrays and I know their sizes, and I will not screw up the limits, etc.

I suppose that would allow for a better optimization by the compiler.

Upvotes: 4

Views: 1687

Answers (1)

CWallach
CWallach

Reputation: 206

Yes. Check out the restrict keyword.

Restrict details

Upvotes: 9

Related Questions