<s>
In	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
restrict	B-Language
is	O
a	O
keyword	O
,	O
introduced	O
by	O
the	O
C99	B-Language
standard	I-Language
,	O
that	O
can	O
be	O
used	O
in	O
pointer	O
declarations	O
.	O
</s>
<s>
By	O
adding	O
this	O
type	B-Language
qualifier	I-Language
,	O
a	O
programmer	O
hints	O
to	O
the	O
compiler	B-Language
that	O
for	O
the	O
lifetime	O
of	O
the	O
pointer	O
,	O
no	O
other	O
pointer	O
will	O
be	O
used	O
to	O
access	O
the	O
object	O
to	O
which	O
it	O
points	O
.	O
</s>
<s>
This	O
allows	O
the	O
compiler	B-Language
to	O
make	O
optimizations	B-Application
(	O
for	O
example	O
,	O
vectorization	O
)	O
that	O
would	O
not	O
otherwise	O
have	O
been	O
possible	O
.	O
</s>
<s>
restrict	B-Language
limits	O
the	O
effects	O
of	O
pointer	O
aliasing	O
,	O
aiding	O
optimizations	B-Application
.	O
</s>
<s>
If	O
the	O
declaration	O
of	O
intent	O
is	O
not	O
followed	O
and	O
the	O
object	O
is	O
accessed	O
by	O
an	O
independent	O
pointer	O
,	O
this	O
will	O
result	O
in	O
undefined	B-Language
behavior	I-Language
.	O
</s>
<s>
If	O
the	O
compiler	B-Language
knows	O
that	O
there	O
is	O
only	O
one	O
pointer	O
to	O
a	O
memory	O
block	O
,	O
it	O
can	O
produce	O
better	O
optimized	O
code	O
.	O
</s>
<s>
In	O
the	O
above	O
code	O
,	O
the	O
pointers	O
ptrA	O
,	O
ptrB	O
,	O
and	O
val	O
might	O
refer	O
to	O
the	O
same	O
memory	O
location	O
,	O
so	O
the	O
compiler	B-Language
may	O
generate	O
less	O
optimal	O
code	O
:	O
</s>
<s>
then	O
the	O
compiler	B-Language
is	O
allowed	O
to	O
assume	O
that	O
ptrA	O
,	O
ptrB	O
,	O
and	O
val	O
point	O
to	O
different	O
locations	O
and	O
updating	O
the	O
memory	O
location	O
referenced	O
by	O
one	O
pointer	O
will	O
not	O
affect	O
the	O
memory	O
locations	O
referenced	O
by	O
the	O
other	O
pointers	O
.	O
</s>
<s>
The	O
programmer	O
,	O
not	O
the	O
compiler	B-Language
,	O
is	O
responsible	O
for	O
ensuring	O
that	O
the	O
pointers	O
do	O
not	O
point	O
to	O
identical	O
locations	O
.	O
</s>
<s>
The	O
compiler	B-Language
can	O
e.g.	O
</s>
<s>
Also	O
,	O
since	O
the	O
compiler	B-Language
can	O
rearrange	O
the	O
code	O
more	O
freely	O
,	O
the	O
compiler	B-Language
can	O
generate	O
code	O
that	O
executes	O
faster	O
.	O
</s>
<s>
Benefit	O
with	O
the	O
above	O
mini-example	O
tends	O
to	O
be	O
small	O
,	O
and	O
in	O
real-life	O
cases	O
large	O
loops	O
doing	O
heavy	O
memory	O
access	O
tends	O
to	O
be	O
what	O
is	O
really	O
helped	O
by	O
restrict	B-Language
.	O
</s>
<s>
As	O
mentioned	O
above	O
,	O
how	O
incorrect	O
code	O
behaves	O
is	O
undefined	B-Language
,	O
the	O
compiler	B-Language
only	O
ensures	O
the	O
generated	O
code	O
works	O
properly	O
if	O
the	O
code	O
follows	O
the	O
declaration	O
of	O
intent	O
.	O
</s>
<s>
C++	B-Language
does	O
not	O
have	O
standard	O
support	O
for	O
restrict	B-Language
,	O
but	O
many	O
compilers	B-Language
have	O
equivalents	O
that	O
usually	O
work	O
in	O
both	O
C++	B-Language
and	O
C	B-Language
,	O
such	O
as	O
the	O
GCC	B-Application
's	O
and	O
Clang	B-Application
's	O
__restrict__	O
,	O
and	O
Visual	O
C++'s	O
__declspec(restrict )	O
.	O
</s>
<s>
In	O
addition	O
,	O
__restrict	O
is	O
supported	O
by	O
those	O
three	O
compilers	B-Language
.	O
</s>
<s>
The	O
exact	O
interpretation	O
of	O
these	O
alternative	O
keywords	O
vary	O
by	O
the	O
compiler	B-Language
:	O
</s>
<s>
In	O
Unix-style	O
compilers	B-Language
such	O
as	O
GCC	B-Application
and	O
Clang	B-Application
,	O
and	O
mean	O
exactly	O
the	O
same	O
as	O
their	O
C	B-Language
counterpart	O
.	O
</s>
<s>
In	O
Visual	B-Application
C++	I-Application
,	O
multiple	O
no-alias	O
qualifiers	O
are	O
provided	O
:	O
</s>
<s>
To	O
help	O
prevent	O
incorrect	O
code	O
,	O
some	O
compilers	B-Language
and	O
other	O
tools	O
try	O
to	O
detect	O
when	O
overlapping	O
arguments	O
have	O
been	O
passed	O
to	O
functions	O
with	O
parameters	O
marked	O
.	O
</s>
<s>
The	O
CERT	B-Language
C	I-Language
Coding	I-Language
Standard	I-Language
considers	O
misuse	O
of	O
and	O
library	O
functions	O
marked	O
with	O
it	O
(	O
EXP43-C	O
)	O
a	O
probable	O
source	O
of	O
software	O
bugs	O
,	O
although	O
as	O
of	O
November	O
2019	O
no	O
vulnerabilities	O
are	O
known	O
to	O
have	O
been	O
caused	O
by	O
this	O
.	O
</s>
