-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Over/Underflow in closed vector limits #98
Comments
This bug is not specific to u8, u16 or even u32 or restricted to unsigned types. The current logic is utterly flawed, e.g. try [0->253[, 50 or step 250 for fun. Here is how Céu could generate a different kind of loop expansion. I'm making use of the excellent overflow detection API introduced with GCC version 5. LLVM supports it too. int main() {
unsigned int ret = 0;
unsigned char start = 0, stop = 0, step = 1;
assert(step > 0); // says the Céu manual
for ( ; start < stop // Use either < with [a -> b[ or <= with [a -> b]
; ({if (__builtin_add_overflow(start,step,&start)) goto end;})) {
// for() supports both break; and continue; statements.
printf(" ..%u", start);
ret = ret + 1;
}
end: // gensym this label, of course
printf(" ->%u\n", ret);
return 0;
} Conversely, a descending loop [ <- ] would use __builtin_sub_overflow(). I'm using another GCC extension, namely ({ statements as expressions }) so that the complete step fits for(;;step) syntax. That allows to support |
thanks |
It's good that ceu-maker 0.40 updated the embedded Arduino package from 1.8.3 to 1.8.8. The old one contains avr-gcc version 4.9.2; however GCC did not support |
The runtime decrements the starting limit
0[
:The text was updated successfully, but these errors were encountered: