<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
bounds	B-Data_Structure
checking	I-Data_Structure
is	O
any	O
method	O
of	O
detecting	O
whether	O
a	O
variable	O
is	O
within	O
some	O
bounds	O
before	O
it	O
is	O
used	O
.	O
</s>
<s>
It	O
is	O
usually	O
used	O
to	O
ensure	O
that	O
a	O
number	O
fits	O
into	O
a	O
given	O
type	O
(	O
range	O
checking	O
)	O
,	O
or	O
that	O
a	O
variable	O
being	O
used	O
as	O
an	O
array	B-Data_Structure
index	O
is	O
within	O
the	O
bounds	O
of	O
the	O
array	B-Data_Structure
(	O
index	O
checking	O
)	O
.	O
</s>
<s>
A	O
failed	O
bounds	B-Data_Structure
check	I-Data_Structure
usually	O
results	O
in	O
the	O
generation	O
of	O
some	O
sort	O
of	O
exception	B-General_Concept
signal	O
.	O
</s>
<s>
As	O
performing	O
bounds	B-Data_Structure
checking	I-Data_Structure
during	O
each	O
use	O
can	O
be	O
time-consuming	O
,	O
it	O
is	O
not	O
always	O
done	O
.	O
</s>
<s>
Bounds-checking	B-Error_Name
elimination	I-Error_Name
is	O
a	O
compiler	B-Application
optimization	I-Application
technique	O
that	O
eliminates	O
unneeded	O
bounds	B-Data_Structure
checking	I-Data_Structure
.	O
</s>
<s>
checking	O
against	O
wrap-around	B-Algorithm
)	O
.	O
</s>
<s>
Index	O
checking	O
means	O
that	O
,	O
in	O
all	O
expressions	O
indexing	O
an	O
array	B-Data_Structure
,	O
the	O
index	O
value	O
is	O
checked	O
against	O
the	O
bounds	O
of	O
the	O
array	B-Data_Structure
(	O
which	O
were	O
established	O
when	O
the	O
array	B-Data_Structure
was	O
defined	O
)	O
,	O
and	O
if	O
the	O
index	O
is	O
out-of-bounds	O
,	O
further	O
execution	O
is	O
suspended	O
via	O
some	O
sort	O
of	O
error	O
.	O
</s>
<s>
Because	O
reading	O
or	O
especially	O
writing	O
a	O
value	O
outside	O
the	O
bounds	O
of	O
an	O
array	B-Data_Structure
may	O
cause	O
the	O
program	O
to	O
malfunction	O
or	O
crash	O
or	O
enable	O
security	O
vulnerabilities	O
(	O
see	O
buffer	B-General_Concept
overflow	I-General_Concept
)	O
,	O
index	O
checking	O
is	O
a	O
part	O
of	O
many	O
high-level	B-Language
languages	I-Language
.	O
</s>
<s>
Early	O
compiled	O
programming	O
languages	O
with	O
index	O
checking	O
ability	O
included	O
ALGOL	B-Language
60	I-Language
,	O
ALGOL	B-Language
68	I-Language
and	O
Pascal	B-Application
,	O
as	O
well	O
as	O
interpreted	O
programming	O
languages	O
such	O
as	O
BASIC	O
.	O
</s>
<s>
Many	O
programming	O
languages	O
,	O
such	O
as	O
C	B-Language
,	O
never	O
perform	O
automatic	O
bounds	B-Data_Structure
checking	I-Data_Structure
to	O
raise	O
speed	O
.	O
</s>
<s>
However	O
,	O
this	O
leaves	O
many	O
off-by-one	B-Error_Name
errors	I-Error_Name
and	O
buffer	B-General_Concept
overflows	I-General_Concept
uncaught	O
.	O
</s>
<s>
In	O
his	O
1980	O
Turing	O
Award	O
lecture	O
,	O
C	B-Language
.	O
A	O
.	O
R	O
.	O
Hoare	O
described	O
his	O
experience	O
in	O
the	O
design	O
of	O
ALGOL	B-Language
60	I-Language
,	O
a	O
language	O
that	O
included	O
bounds	B-Data_Structure
checking	I-Data_Structure
,	O
saying	O
:	O
</s>
<s>
A	O
consequence	O
of	O
this	O
principle	O
is	O
that	O
every	O
occurrence	O
of	O
every	O
subscript	O
of	O
every	O
subscripted	O
variable	O
was	O
on	O
every	O
occasion	O
checked	O
at	O
run	O
time	O
against	O
both	O
the	O
upper	O
and	O
the	O
lower	O
declared	O
bounds	O
of	O
the	O
array	B-Data_Structure
.	O
</s>
<s>
Mainstream	O
languages	O
that	O
enforce	O
run	O
time	O
checking	O
include	O
Ada	B-Language
,	O
C#	B-Application
,	O
Haskell	B-Language
,	O
Java	B-Language
,	O
JavaScript	B-Language
,	O
Lisp	B-Language
,	O
PHP	B-Application
,	O
Python	B-Language
,	O
Ruby	B-Language
,	O
Rust	B-Application
,	O
and	O
Visual	B-Language
Basic	I-Language
.	O
</s>
<s>
The	O
D	B-Application
and	O
OCaml	B-Language
languages	O
have	O
run	O
time	O
bounds	B-Data_Structure
checking	I-Data_Structure
that	O
is	O
enabled	O
or	O
disabled	O
with	O
a	O
compiler	O
switch	O
.	O
</s>
<s>
In	O
C++	B-Language
run	O
time	O
checking	O
is	O
not	O
part	O
of	O
the	O
language	O
,	O
but	O
part	O
of	O
the	O
STL	B-Application
and	O
is	O
enabled	O
with	O
a	O
compiler	O
switch	O
( _GLIBCXX_DEBUG	O
=	O
1	O
or	O
_LIBCPP_DEBUG	O
=	O
1	O
)	O
.	O
</s>
<s>
C#	B-Application
also	O
supports	O
unsafe	O
regions	O
:	O
sections	O
of	O
code	O
that	O
(	O
among	O
other	O
things	O
)	O
temporarily	O
suspend	O
bounds	B-Data_Structure
checking	I-Data_Structure
to	O
raise	O
efficiency	O
.	O
</s>
<s>
The	O
JS++	B-Language
programming	O
language	O
is	O
able	O
to	O
analyze	O
if	O
an	O
array	B-Data_Structure
index	O
or	O
map	O
key	O
is	O
out-of-bounds	O
at	O
compile	O
time	O
using	O
existent	O
types	O
,	O
which	O
is	O
a	O
nominal	O
type	O
describing	O
whether	O
the	O
index	O
or	O
key	O
is	O
within-bounds	O
or	O
out-of-bounds	O
and	O
guides	O
code	O
generation	O
.	O
</s>
<s>
The	O
safety	O
added	O
by	O
bounds	B-Data_Structure
checking	I-Data_Structure
necessarily	O
costs	O
CPU	B-Device
time	O
if	O
the	O
checking	O
is	O
performed	O
in	O
software	O
;	O
however	O
,	O
if	O
the	O
checks	O
could	O
be	O
performed	O
by	O
hardware	O
,	O
then	O
the	O
safety	O
can	O
be	O
provided	O
"	O
for	O
free	O
"	O
with	O
no	O
runtime	O
cost	O
.	O
</s>
<s>
An	O
early	O
system	O
with	O
hardware	O
bounds	B-Data_Structure
checking	I-Data_Structure
was	O
the	O
ICL	B-Device
2900	I-Device
Series	I-Device
mainframe	O
announced	O
in	O
1974	O
.	O
</s>
<s>
The	O
VAX	B-Device
computer	O
has	O
an	O
INDEX	O
assembly	O
instruction	O
for	O
array	B-Data_Structure
index	O
checking	O
which	O
takes	O
six	O
operands	O
,	O
all	O
of	O
which	O
can	O
use	O
any	O
VAX	B-Device
addressing	O
mode	O
.	O
</s>
<s>
A	O
limited	O
number	O
of	O
later	O
CPUs	B-Device
have	O
specialised	O
instructions	O
for	O
checking	O
bounds	O
,	O
e.g.	O
,	O
the	O
CHK2	O
instruction	O
on	O
the	O
Motorola	O
68000	O
series	O
.	O
</s>
<s>
Research	O
has	O
been	O
underway	O
since	O
at	O
least	O
2005	O
regarding	O
methods	O
to	O
use	O
x86	O
's	O
built-in	O
virtual	O
memory	O
management	O
unit	O
to	O
ensure	O
safety	O
of	O
array	B-Data_Structure
and	O
buffer	O
accesses	O
.	O
</s>
<s>
In	O
2015	O
Intel	O
provided	O
their	O
Intel	B-Device
MPX	I-Device
extensions	O
in	O
their	O
Skylake	B-Architecture
processor	O
architecture	O
which	O
stores	O
bounds	O
in	O
a	O
CPU	B-Device
register	O
and	O
table	O
in	O
memory	O
.	O
</s>
