Fix strict-aliasing warnings from unwind-dw2-fde.c
Jeff Law
law@redhat.com
Wed Nov 21 17:11:00 GMT 2012
On 11/21/2012 10:04 AM, Joseph S. Myers wrote:
> On platforms with SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2_5), such as
> x86 and MIPS, there are several "dereferencing type-punned pointer
> will break strict-aliasing rules" warnings from unwind-dw2-fde.c
> (accessing _Unwind_Ptr and pointer types through a char[] array, when
> only the other way round is valid under C aliasing rules).
>
> This patch fixes these warnings by using memcpy in an inline function
> to extract the values from the array. Tested x86, and tested on MIPS
> (all three ABIs) that it also eliminates the warnings there.
>
> 2012-11-21 Joseph Myers <joseph@codesourcery.com>
>
> * sysdeps/generic/unwind-dw2-fde.c (get_pc_begin): New function.
> (fde_unencoded_compare): Use get_pc_begin instead of type-punning.
> (add_fdes): Likewise.
> (linear_search_fdes): Likewise.
> (binary_search_unencoded_fdes): Likewise.
How interested are we in fixing these warnings? There's a patch in
fedora which adds -fno-strict-aliasing to the compilation lines for ~10
or so files in glibc.
It wouldn't be terribly hard to revert that change in Fedora and see
what still triggers, then either fix the source or add the
-fno-strict-aliasing flag.
Jeff
More information about the Libc-alpha
mailing list