[Issue 5906] Just pre-conditions at compile-time when arguments are static
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 7 19:34:04 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5906
--- Comment #12 from yebblies <yebblies at gmail.com> 2013-03-08 14:33:58 EST ---
(In reply to comment #10)
>
> I see, thank you for the answer.
> If the pre-condition analysis (constant folding) is done after a normal step of
> dead branch removal, then maybe that error will not be shown.
> Currently it doesn't happen, and this generates an error (you need a "static if" to make the error go away):
That is an interesting point.
I seriously doubt that would be enough anyway, I think you would need full flow
analysis to work out which paths can actually be taken.
Another good example is this:
int div(int a, int b)
in
{
assert(b != 0, "Division by zero!");
}
body
{
return a / b;
}
void main(string[] args)
{
auto i = 3 / 0; // Fails at compile time
auto j = div(3, 0); // Would fail at compile time if this was implemented
}
So maybe it is acceptable.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list