Skip to content

[BUG] Compiler warnings in foc_utils.cpp #296

Open
@jadoro

Description

@jadoro

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions