On 07.12.2010 06:57, %u wrote:
Yay for more comments like this one.Don 2010-12-06 11:53:27 PST -- Bearophile -- That's an interesting [automatic fuzzy testing]link. Currently, DMD back-end bugs are being found at the rate of about 3 per year. So yes, fuzzy testing of DMC could probably flush out some backend bugs a bit faster. ------------------- Here's what's happening. First, in this code: for (int i = 0; i< 10; i++) { foo(i * 5 - 6); } it sees that i and 10 are always>=0, so the signed comparison "i< 10" is replaced with an unsigned one. (This happens in the backend in constprop() ). Then, while dealing with loop invariants, it rewrites the loop into: for (int _i2 = -6; _i2< 10*5 - 6; _i2 += 5) { foo(_i2); } Fine. Except that it had changed the comparison into an unsigned one! Particularly interesting is the case where the call is foo(i*5-50); Then, the loop becomes: for (int _i2 = -50; _i2< 0; _i2 += 5) Since an unsigned value is NEVER less than zero, it just drops the loop completely! Nasty. -- http://d.puremagic.com/issues/show_bug.cgi?id=5294
What i think is more disturbing is Walters response:
I'm not sure how to fix that one yet, but it has been there for 25 years now, so I am not sure it is urgent!
I often ran into this strange behaviour when using -O optimization without knowing where it came from and it is so disturbing when i think of people newly getting interested in D making the experience when trying to compare it with C/C++ and then finding out the optimization makes strange things. I think out of a image perspective such bugs must be high priority, ESPECIALLY if it lies there for 25years already.
Regards, Stephan
