exception and integer overflow
Sebastian Philipp
sebastian_p at wh.fh-wedel.de
Sun Apr 15 05:06:02 PDT 2007
Hello,
is it possible to check for integer overflows?
$ cat test.d; dmd -w *.d; ./test
import std.stdio;
int main(char[][] args)
{
uint i = 0, j = uint.max;;
writefln("i = ",i, ";j = ",j);
try
{
--i;++j;
}
catch (Exception e)
{
writefln("exception!");
}
writefln("i = ",i, ";j = ",j);
return 0;
}
gcc test.o -o test -m32 -lphobos -lpthread -lm
i = 0;j = 4294967295
i = 4294967295;j = 0
Where is my fault?
Sebastian
More information about the Digitalmars-d-learn
mailing list