Compiler Warning for arm_math.h

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am receiving the following compiler warning when compiling my project:

Warning        cast increases required alignment of target type [-Wcast-align]    ...\src\ASF\thirdparty\CMSIS\Include\arm_math.h    483

Line 483 of arm_math.h is here:

#define __SIMD32_CONST(addr)  ((__SIMD32_TYPE *)(addr))

Of possible relevance are earlier lines (453 - 456):

#elif defined ( __GNUC__ )
  #define __SIMD32_TYPE int32_t
  #define CMSIS_UNUSED __attribute__((unused))
  #define CMSIS_INLINE __attribute__((always_inline))

 

As far as I know, arm_math.h is unmodified from what was provided with the ASF--I've not gone in and changed anything in there. I also searched my entire solution, and the statement "__SIMD32_CONST" does not appear anywhere outside of arm_math.h.

 

I am using Atmel Studio 7.0.2397. My project is built on ASF 3.49.1, targeting a SAM E70 chip, and using gcc 6.3.1.

 

I do use the math function, exp2, in one of my functions within a C file, so I include "arm_math.h" to gain access to it. Should I be concerned about this compiler warning? Is it a bug in ASF? Should I ignore it? Thanks!
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the warning is trying to say that casing "addr" to a 32_bit pointer requires that "addr" is on a 4 byte boundary.  If you specify "addr" as a 32 bit value then its already 4 byte aligned, so it should not be a problem, but if "addr" is an 8 bit value, then then it may not be aligned on a 4 bye boundary.

 

Note you can remove warnings from individual files in Atmel Studio by clicking on the file in solution explorer, and setting "Custom Compilation Setting", then typing "no-" if front of the warning name, To remove " -Wcast-align" type "-Wno-cast-align"

John Malaugh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

malaugh wrote:

Note you can remove warnings from individual files in Atmel Studio by clicking on the file in solution explorer, and setting "Custom Compilation Setting", then typing "no-" if front of the warning name, To remove " -Wcast-align" type "-Wno-cast-align"

 

Nice tip! I was not aware of that functionality.

 

For the record, this compiler warning for the built-in ASF3 "arm_math.h" file is replicable by opening an Example Project from Atmel Studio that uses "arm_math.h". For example, create "CMSIS DSP Sin Cos Example - SAME70-XPLD" from Atmel Studio then Rebuild Solution. The same compiler warning from my original post is seen.