Re: [xml] Do we need to be concerned about cast-align warnings?

Andrew Black <andrew black realvnc com> wrote:

Hi all,

When compiling libxml2 for ARM, I get alot of cast-align warnings, e.g.
from this line:<>

This generates the warning message: "cast increases required alignment of
target type". My question: is this something to be concerned about? What
might be the consequences if someone passes a char* that is not suitably
aligned for casting to a (short*)?

Depends on the hardware.  Builds for MIPS generate similar warnings.

ARMs can be configured to abort on unaligned loads, or you can get a rotated
load (we used to use that trick on old ARMs to optimise things :-)

It's not possible to say whether you need to worry about it or not without
examining each use.  Ideally, if the alignment is not important, it'd be
better if the code was using void* rather than char*.  Some code uses char*
because it wants to do arithmetic on the pointers; some because it pre-dates
the introduction of the void type in C89!

Stewart Brodie
Senior Software Engineer
Espial UK

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]