<s>
In	O
computing	O
(	O
particularly	O
,	O
in	O
programming	B-General_Concept
)	O
,	O
undefined	B-General_Concept
value	I-General_Concept
is	O
a	O
condition	O
where	O
an	O
expression	O
does	O
not	O
have	O
a	O
correct	O
value	O
,	O
although	O
it	O
is	O
syntactically	O
correct	O
.	O
</s>
<s>
An	O
undefined	B-General_Concept
value	I-General_Concept
must	O
not	O
be	O
confused	O
with	O
empty	O
string	O
,	O
Boolean	O
"	O
false	O
"	O
or	O
other	O
"	O
empty	O
"	O
(	O
but	O
defined	O
)	O
values	O
.	O
</s>
<s>
Depending	O
on	O
circumstances	O
,	O
evaluation	O
to	O
an	O
undefined	B-General_Concept
value	I-General_Concept
may	O
lead	O
to	O
exception	B-General_Concept
or	O
undefined	B-Language
behaviour	I-Language
,	O
but	O
in	O
some	O
programming	B-General_Concept
languages	O
undefined	B-General_Concept
values	I-General_Concept
can	O
occur	O
during	O
a	O
normal	O
,	O
predictable	O
course	O
of	O
program	B-Application
execution	O
.	O
</s>
<s>
Dynamically	O
typed	O
languages	O
usually	O
treat	O
undefined	B-General_Concept
values	I-General_Concept
explicitly	O
when	O
possible	O
.	O
</s>
<s>
For	O
instance	O
,	O
Perl	B-Language
has	O
undef	O
operator	O
which	O
can	O
"	O
assign	O
"	O
such	O
value	O
to	O
a	O
variable	O
.	O
</s>
<s>
In	O
other	O
type	O
systems	O
an	O
undefined	B-General_Concept
value	I-General_Concept
can	O
mean	O
an	O
unknown	O
,	O
unpredictable	O
value	O
,	O
or	O
merely	O
a	O
program	B-Application
failure	O
on	O
attempt	O
of	O
its	O
evaluation	O
.	O
</s>
<s>
The	O
value	O
of	O
a	O
partial	B-Algorithm
function	I-Algorithm
is	O
undefined	O
when	O
its	O
argument	O
is	O
out	O
of	O
its	O
domain	B-Algorithm
of	I-Algorithm
definition	I-Algorithm
.	O
</s>
<s>
This	O
include	O
numerous	O
arithmetical	O
cases	O
such	O
as	O
division	B-Algorithm
by	I-Algorithm
zero	I-Algorithm
,	O
square	O
root	O
or	O
logarithm	O
of	O
a	O
negative	O
number	O
etc	O
.	O
</s>
<s>
Another	O
common	O
example	O
is	O
accessing	O
an	O
array	B-Data_Structure
with	O
an	O
index	O
which	O
is	O
out	O
of	O
bounds	O
,	O
as	O
is	O
the	O
value	O
in	O
an	O
associative	B-Application
array	I-Application
for	O
a	O
key	O
which	O
it	O
does	O
not	O
contain	O
.	O
</s>
<s>
In	O
applications	O
where	O
undefined	B-General_Concept
values	I-General_Concept
must	O
be	O
handled	O
gracefully	O
,	O
it	O
is	O
common	O
to	O
reserve	O
a	O
special	O
null	B-Language
value	O
which	O
is	O
distinguishable	O
from	O
normal	O
values	O
.	O
</s>
<s>
The	O
C	B-Language
standard	B-Language
I/O	I-Language
library	I-Language
reserves	O
the	O
special	O
value	O
EOF	B-Language
to	O
indicate	O
that	O
no	O
more	O
input	O
is	O
available	O
.	O
</s>
<s>
The	O
getchar( )	O
function	O
returns	O
the	O
next	O
available	O
input	O
character	O
,	O
or	O
EOF	B-Language
if	O
there	O
is	O
no	O
more	O
available	O
.	O
</s>
<s>
(	O
The	O
ASCII	B-Protocol
character	I-Protocol
code	O
defines	O
a	O
null	B-Language
character	O
for	O
this	O
purpose	O
,	O
but	O
the	O
standard	B-Language
I/O	I-Language
library	I-Language
wishes	O
to	O
be	O
able	O
to	O
send	O
and	O
receive	O
null	B-Language
characters	O
,	O
so	O
it	O
defines	O
a	O
separate	O
EOF	B-Language
value	O
.	O
)	O
</s>
<s>
The	O
IEEE	O
754	O
floating-point	O
arithmetic	O
standard	O
defines	O
a	O
special	O
"	O
not	O
a	O
number	O
"	O
value	O
which	O
is	O
returned	O
when	O
an	O
arithmetic	O
operation	O
has	O
no	O
defined	O
value	O
.	O
</s>
<s>
Examples	O
are	O
division	B-Algorithm
by	I-Algorithm
zero	I-Algorithm
,	O
or	O
the	O
square	O
root	O
or	O
logarithm	O
of	O
a	O
negative	O
number	O
.	O
</s>
<s>
Structured	B-Language
Query	I-Language
Language	I-Language
has	O
a	O
special	O
NULL	B-Language
value	O
to	O
indicate	O
missing	O
data	O
.	O
</s>
<s>
The	O
Perl	B-Language
language	I-Language
lets	O
the	O
definedness	O
of	O
an	O
expression	O
be	O
checked	O
via	O
the	O
defined( )	O
predicate	O
.	O
</s>
<s>
Many	O
programming	B-General_Concept
languages	O
support	O
the	O
concept	O
of	O
a	O
null	B-Language
pointer	O
distinct	O
from	O
any	O
valid	O
pointer	O
,	O
and	O
often	O
used	O
as	O
an	O
error	O
return	O
.	O
</s>
<s>
Some	O
languages	O
allow	O
most	O
types	O
to	O
be	O
nullable	O
,	O
for	O
example	O
C#	B-Application
.	O
</s>
<s>
Most	O
Unix	B-Application
system	I-Application
calls	O
return	O
the	O
special	O
value	O
1	O
to	O
indicate	O
failure	O
.	O
</s>
<s>
While	O
dynamically	O
typed	O
languages	O
often	O
ensure	O
that	O
uninitialized	B-Error_Name
variables	I-Error_Name
default	O
to	O
a	O
null	B-Language
value	O
,	O
statically	O
typed	O
values	O
often	O
do	O
not	O
,	O
and	O
distinguish	O
null	B-Language
values	O
(	O
which	O
are	O
well-defined	O
)	O
from	O
uninitialized	O
values	O
(	O
which	O
are	O
not	O
)	O
.	O
</s>
<s>
Some	O
programming	B-General_Concept
languages	O
have	O
a	O
concept	O
of	O
exception	B-General_Concept
handling	I-General_Concept
for	O
dealing	O
with	O
failure	O
to	O
return	O
a	O
value	O
.	O
</s>
<s>
A	O
variation	O
on	O
this	O
is	O
signal	B-Operating_System
handling	I-Operating_System
,	O
which	O
is	O
done	O
at	O
the	O
operating	O
system	O
level	O
and	O
not	O
integrated	O
into	O
a	O
programming	B-General_Concept
language	O
.	O
</s>
<s>
Signal	B-Operating_System
handlers	I-Operating_System
can	O
attempt	O
some	O
forms	O
of	O
recovery	O
,	O
such	O
as	O
terminating	O
part	O
of	O
a	O
computation	O
,	O
but	O
without	O
as	O
much	O
flexibility	O
as	O
fully	O
integrated	O
exception	B-General_Concept
handling	I-General_Concept
.	O
</s>
<s>
A	O
function	O
which	O
never	O
returns	O
has	O
an	O
undefined	B-General_Concept
value	I-General_Concept
because	O
the	O
value	O
can	O
never	O
be	O
observed	O
.	O
</s>
<s>
Functions	O
which	O
loop	B-Algorithm
forever	I-Algorithm
.	O
</s>
<s>
Functions	O
which	O
terminate	B-Operating_System
the	O
computation	O
,	O
such	O
as	O
the	O
exit	O
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
From	O
within	O
the	O
program	B-Application
,	O
this	O
is	O
indistinguishable	O
from	O
the	O
preceding	O
case	O
,	O
but	O
it	O
makes	O
a	O
difference	O
to	O
the	O
invoker	O
of	O
the	O
program	B-Application
.	O
</s>
<s>
All	O
of	O
the	O
preceding	O
methods	O
of	O
handling	O
undefined	B-General_Concept
values	I-General_Concept
require	O
that	O
the	O
undefinedness	O
be	O
detected	O
.	O
</s>
<s>
At	O
the	O
other	O
end	O
of	O
the	O
spectrum	O
,	O
undefined	B-Language
behaviour	I-Language
places	O
the	O
onus	O
on	O
the	O
caller	O
to	O
avoid	O
calling	O
a	O
function	O
with	O
arguments	O
outside	O
of	O
its	O
domain	O
.	O
</s>
<s>
At	O
best	O
,	O
an	O
easily	O
detectable	O
crash	B-General_Concept
;	O
at	O
worst	O
,	O
a	O
subtle	O
error	O
in	O
a	O
seemingly	O
unrelated	O
computation	O
.	O
</s>
<s>
(	O
The	O
formal	O
definition	O
of	O
"	O
undefined	B-Language
behaviour	I-Language
"	O
includes	O
even	O
more	O
extreme	O
possibilities	O
,	O
including	O
things	O
like	O
"	O
halt	B-Language
and	I-Language
catch	I-Language
fire	I-Language
"	O
and	O
"	O
make	O
demons	O
fly	O
out	O
of	O
your	O
nose	O
"	O
.	O
)	O
</s>
<s>
The	O
classic	O
example	O
is	O
a	O
dangling	B-Error_Name
pointer	I-Error_Name
reference	O
.	O
</s>
<s>
Therefore	O
,	O
computer	O
hardware	O
and	O
low-level	O
languages	O
such	O
as	O
C	B-Language
do	O
not	O
attempt	O
to	O
validate	O
pointers	O
before	O
dereferencing	O
them	O
,	O
instead	O
passing	O
responsibility	O
to	O
the	O
programmer	O
.	O
</s>
<s>
The	O
strict	O
definition	O
of	O
an	O
undefined	B-General_Concept
value	I-General_Concept
is	O
a	O
superficially	O
valid	O
(	O
non-null	O
)	O
output	O
which	O
is	O
meaningless	O
but	O
does	O
not	O
trigger	O
undefined	B-Language
behaviour	I-Language
.	O
</s>
<s>
Undefined	B-General_Concept
values	I-General_Concept
occur	O
particularly	O
often	O
in	O
hardware	O
.	O
</s>
<s>
The	O
same	O
situation	O
occurs	O
in	O
software	O
when	O
a	O
data	B-General_Concept
buffer	I-General_Concept
is	O
provided	O
but	O
not	O
completely	O
filled	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
C	B-Language
library	O
strftime	O
function	O
converts	O
a	O
timestamp	O
to	O
human-readable	O
form	O
in	O
a	O
supplied	O
output	O
buffer	B-General_Concept
.	O
</s>
<s>
If	O
the	O
output	O
buffer	B-General_Concept
is	O
not	O
large	O
enough	O
to	O
hold	O
the	O
result	O
,	O
an	O
error	O
is	O
returned	O
and	O
the	O
buffer	B-General_Concept
's	O
contents	O
are	O
undefined	O
.	O
</s>
<s>
In	O
the	O
other	O
direction	O
,	O
the	O
open	B-Language
system	I-Language
call	I-Language
in	O
POSIX	O
takes	O
three	O
arguments	O
:	O
a	O
file	O
name	O
,	O
some	O
flags	O
,	O
and	O
a	O
file	O
mode	O
.	O
</s>
<s>
It	O
is	O
common	O
to	O
use	O
a	O
two-argument	O
form	O
of	O
open	O
,	O
which	O
provides	O
an	O
undefined	B-General_Concept
value	I-General_Concept
for	O
the	O
file	O
mode	O
,	O
when	O
O_CREAT	O
is	O
omitted	O
.	O
</s>
<s>
Sometimes	O
it	O
is	O
useful	O
to	O
work	O
with	O
such	O
undefined	B-General_Concept
values	I-General_Concept
in	O
a	O
limited	O
way	O
.	O
</s>
<s>
The	O
overall	O
computation	O
can	O
still	O
be	O
well-defined	O
if	O
the	O
undefined	B-General_Concept
value	I-General_Concept
is	O
later	O
ignored	O
.	O
</s>
<s>
As	O
an	O
example	O
of	O
this	O
,	O
the	O
C	B-Language
language	I-Language
permits	O
converting	O
a	O
pointer	O
to	O
an	O
integer	O
,	O
although	O
the	O
numerical	O
value	O
of	O
that	O
integer	O
is	O
undefined	O
.	O
</s>
<s>
It	O
may	O
still	O
be	O
useful	O
for	O
debugging	O
,	O
for	O
comparing	O
two	O
pointers	O
for	O
equality	O
,	O
or	O
for	O
creating	O
an	O
XOR	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
Safely	O
handling	O
undefined	B-General_Concept
values	I-General_Concept
is	O
important	O
in	O
optimistic	B-Operating_System
concurrency	I-Operating_System
control	I-Operating_System
systems	O
,	O
which	O
detect	O
race	B-Operating_System
conditions	I-Operating_System
after	O
the	O
fact	O
.	O
</s>
<s>
For	O
example	O
,	O
reading	O
a	O
shared	B-Language
variable	I-Language
protected	O
by	O
seqlock	B-Application
will	O
produce	O
an	O
undefined	B-General_Concept
value	I-General_Concept
before	O
determining	O
that	O
a	O
race	B-Operating_System
condition	I-Operating_System
happened	O
.	O
</s>
<s>
This	O
produces	O
a	O
defined	O
result	O
as	O
long	O
as	O
the	O
operations	O
performed	O
on	O
the	O
undefined	B-General_Concept
values	I-General_Concept
do	O
not	O
produce	O
full-fledged	O
undefined	B-Language
behaviour	I-Language
.	O
</s>
<s>
Other	O
examples	O
of	O
undefined	B-General_Concept
values	I-General_Concept
being	O
useful	O
are	O
random	O
number	O
generators	O
and	O
hash	B-Error_Name
functions	I-Error_Name
.	O
</s>
