dmd 2.029 release
bearophile
bearophileHUGS at lycos.com
Tue Apr 21 07:46:18 PDT 2009
I have tried the following code:
import std.c.stdio: printf;
import std.conv: to;
nothrow pure int double_sqr(int x) { // line 4
int y, z;
nothrow void do_sqr() { y *= y; }
y = x;
do_sqr();
z += y;
y = x;
do_sqr();
z += y;
return z;
}
void main(string[] args) {
int x = args.length == 2 ? to!(int)(args[1]) : 10;
int y = double_sqr(x) + double_sqr(x);
printf("4 * x * x = %d\n", y);
}
The compiler spits the following error:
pure_impure_test.d(4): Error: function pure_impure_test.double_sqr 'double_sqr' is nothrow yet may throw
but I don't understand why. What are the things inside it that can throw an exception?
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list