[fpc-devel] alignment warnings

Henry Vermaak henry.vermaak at gmail.com
Fri Sep 30 12:00:51 CEST 2011


On 30/09/11 10:52, Martin wrote:
> On 30/09/2011 10:44, Henry Vermaak wrote:
>> Hi list
>>
>> 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.
>
> Why limit it to "on machines where ... can only be accessed at ...
> boundaries".
> If code is written for multiply platforms, then the implementor may be
> on a machine where the cast is allowed, and needs no warning, but soon
> as the code is compiled on a different architecture, the warnings come up.
> It would be good, if one could also enable warnings for code, that may
> have issues on other platforms

Because you may be writing code that's specific to a platform?  I guess 
you can have another option that will warn on all machines.

Henry



More information about the fpc-devel mailing list