Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

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.

like image 708
xaxa Avatar asked Sep 06 '25 19:09

xaxa


1 Answers

Yes. Check out the restrict keyword.

Restrict details

like image 171
CWallach Avatar answered Sep 10 '25 05:09

CWallach