This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fstrict-aliasing, -Wstrict-aliasing=2, and indirect conversions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]