I'm facing a weird issue when testing my software on arm64.
I've written a bit of code to reproduce the issue :
char c;
int sum = 0;
for (int i = 0; i <= 255; i++)
{
c = i;
int a = c * 10;
sum += a;
std::cout << a << std::endl;
}
When I run it on Windows (built with Visual Studio 2017) or Ubuntu x64 (gcc 9.3.0-17) I have the following results :
0
10
...
1260
1270
-1280
-1270
-20
-10
sum=-1280
if I run the same code on Ubuntu arm64 (gcc 9.3.0-17), I have different results :
0
10
...
1260
1270
1280
1290
...
2540
2550
sum=326400
I don't know if there is some extra optimization in gcc on arm64 (using -O3) or if there is some issue I don't see ? Any idea on how I can solve this issue?