This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -fstrict-aliasing, -Wstrict-aliasing=2, and indirect conversions
- From: Ian Lance Taylor <ian at airs dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 26 Jul 2005 23:10:37 -0700
- Subject: Re: -fstrict-aliasing, -Wstrict-aliasing=2, and indirect conversions
- References: <42E6CE1E.3080200@gentoo.org> <m3br4pc6un.fsf@gossamer.airs.com>
Ian Lance Taylor <ian@airs.com> writes:
> 2005-07-26 Ian Lance Taylor <ian@airs.com>
>
> * c-typeck.c (build_c_cast): For warn_strict_aliasing warnings,
> use STRIP_NOPS on the operand.
For the record, this patch fails bootstrap, because it triggers
warnings for uses of CONST_DOUBLE_REAL_VALUE. For example:
../../gcc/gcc/cse.c: In function ‘hash_rtx’:
../../gcc/gcc/cse.c:2255: warning: dereferencing type-punned pointer will break strict-aliasing rules
My understanding is that the warnings are valid: the macro
CONST_DOUBLE_REAL_VALUE casts the address of a HOST_WIDE_INT to struct
real_value *, which does violate strict aliasing rules:
#define CONST_DOUBLE_REAL_VALUE(r) ((struct real_value *)&CONST_DOUBLE_LOW(r))
It will never actually matter, because for any given tree node, gcc
will consistently use either CONST_DOUBLE_REAL_VALUE or
CONST_DOUBLE_LOW. But the warnings with -Werror breaks the bootstrap.
I suppose the right fix is to change CONST_DOUBLE_REAL_VALUE to work
in some other way.
Ian