Closed alexalkis closed 3 years ago
that's a general gcc-6 bug - nothing amiga specific.
the calculation in the loop gets optimized to:
x = (y + -1) + x;
y = (x + -1) + y;
and the best: that optimization is done inside the c-parser! use
#include <stdio.h>
#include <time.h>
void intmath(void) {
int x = 0;
int y = 3;
short int i;
for(i = 1; i<=10000; ++i) {
int yy = y*y;
x = x + ( yy-y ) / y;
int xx = x*x;
y = y + ( xx-x ) / x;
}
printf("Finish : %d\n", x);
}
ok. Thanks!
everything is ok: "by default GCC assumes there will be no overflow with integer arithmetic"
=> use -fno-strict-overflow
to disable such optimizations.
it's not a bug, it's a feature.
foo is natively compiled in linux. Gives different result in final value of 'x'.