[fpc-devel] alignment warnings
Ludo Brands
ludo.brands at free.fr
Sat Oct 1 13:38:04 CEST 2011
> >> Thinking more about the alignment problems on arm and elsewhere, I
> >> was wondering how hard it would be to implement something
> like gcc's
> >> -Wcast-align. Here's a description from the man page:
> >>
> >> Warn whenever a pointer is cast such that the required
> alignment of
> >> the target is increased. For example, warn if a "char *"
> is cast to
> >> an "int *" on machines where integers can only be accessed
> at two- or
> >> four-byte boundaries.
> >
> > The problem with such warnings is that one cannot get easily rid of
> > them. Maybe a hint would be more suitable.
>
> Yes, probably, you would want to switch this off most of the
> time, I guess. Is this hard to implement?
>
One of the difficulties is probably pointers to packed records. Depending on
the members of the record the alignment requirement can be 1,2,4 or more
bytes. OS API's contain a lot of these.
Packed records are an aligment "hazard" on their own. They also could use a
warning/hint when members are not on a correctly aligned offset.
Ludo
More information about the fpc-devel
mailing list