Checking for -fstrict-aliasing

Martin Sebor msebor@redhat.com
Wed May 27 16:24:00 GMT 2015


On 05/27/2015 05:09 AM, Florian Weimer wrote:
> Is there a way to check for strict aliasing mode in the preprocessor?
>
> I would like to add warnings to those glibc header files which define
> interfaces with inherent aliasing violations.

I don't think there is such a macro but I'm curious about
the nature  of the aliasing violations and where they occur.
For instance, do they occur in public headers (e.g., by
virtue of the interfaces being defined there as inline
functions or some such) or in the implementation of the
interfaces in library sources? Is fixing the aliasing
violations not feasible? Did you consider the may_alias
attribute to annotate the code with these violations, or
using #pragma GCC optimize to selectively disable strict
aliasing for the affected functions?

Martin



More information about the Gcc-help mailing list