dimanche 19 avril 2015

What differences in c/c++ language in arm and x86 architectures [closed]

I'm trying to port code originally written for x86 architecture to arm.


http://ift.tt/1EgkETz


Originally it was developed for msvc/win32 and has many bugs in code, so there may be UB.


Code is working on x86 when compiled with gcc, but on arm it has different behaviour. It seems to lose some data in arrays and weapon switch does not work. It affected both server and client libraries.


Application is single-threaded, so it is not synchronization problem.


Char is unsigned by default on arm, so i add -fsigned-char to compiler flags, but it didn't solved the problem. What other differences is there between arm and x86 c code?


I tried to compile code on arm with gcc and clang and there is no differences, so it is not a compiler bug.


P.S I compiled code for x86 with gcc-4.9 (instead of 4.8) and got same behaviour. After that i combined two compilers and found that problem was in net_encode.c.


By the time, sebastien chevalier found that


iValue /= pField->multiplier; iValue *= pField->multiplier;


when iValue is integer and pField->multiplier==1.0f sometimes changes integer values.


It can be fixed by adding check if pField->multiplier != 1.0f before multiply.


Aucun commentaire:

Enregistrer un commentaire