Andrew Black <andrew.bl...@realvnc.com> wrote:

> Hi all,
> 
> 
> When compiling libxml2 for ARM, I get alot of cast-align warnings, e.g.
from this line:
>
https://git.gnome.org/browse/libxml2/tree/encoding.c#n491.<https://git.gnome.org/browse/libxml2/tree/encoding.c#n491>
> 
> 
> 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
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to