Arduino-FOC icon indicating copy to clipboard operation
Arduino-FOC copied to clipboard

[BUG] Compiler warnings in foc_utils.cpp

Open jadoro opened this issue 2 years ago • 0 comments

When building SimpleFOC (with -Wall), I get the following compiler warnings – which unfortunately prevent a build with -Werror:

.pio/libdeps/nanoatmega328/Simple FOC/src/common/foc_utils.cpp: In function 'float _sqrtApprox(float)':
.pio/libdeps/nanoatmega328/Simple FOC/src/common/foc_utils.cpp:68:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   i = * ( long * ) &y;
                     ^
.pio/libdeps/nanoatmega328/Simple FOC/src/common/foc_utils.cpp:70:22: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   y = * ( float * ) &i;
                      ^

I'm using PlatformIO for building, with tool versions

framework-arduino-avr @ 5.1.0 
toolchain-atmelavr @ 1.70300.191015 (7.3.0)
Simple FOC @ 2.3.0

The responsible code section already links to Wikipedia, where alternative, more modern versions of that snippet can be found.

jadoro avatar Jul 24 '23 14:07 jadoro