This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
rs6000.c warnings
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Zack Weinberg <zack at codesourcery dot com>, ghazi at caip dot rutgers dot edu
- Date: Wed, 20 Mar 2002 14:55:08 -0500
- Subject: rs6000.c warnings
[I am explicitly cc'ing Zack and Kaveh because they have a lot of
experience with warnings and seem to have opinions about this subject :-]
rs6000.c currently produces
warning: signed and unsigned type in conditional expression
because of the RS6000_ARG_SIZE macro:
#define RS6000_ARG_SIZE(MODE, TYPE) \
((MODE) != BLKmode \
? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD \
: ((unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) \
+ (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
The warning occurs because UNITS_PER_WORD is an integer constant
assumed signed and int_size_in_bytes is not constant. The code in
c-typeck.c to build a conditional expression skips the warning if the
expression is constant, but the function call defeats that exception.
This appears to be GCC being a little overly-aggressize with warnings.
I can remove the warning by REMOVING the cast of int_size_in_bytes
to unsigned H_W_I. This macro only is used to set or modify "int", so
making the expression signed isn't a problem. I could change
UNITS_PER_WORD to constants with "u" appended (which also fixes the
warning), but that is not too appealing.
I am not sure what promotion will occur. Removing the cast makes
one part of the expression unsigned (GET_MODE_SIZE) and the other part
signed (int_size_in_bytes). A warning that encourages me to make an
expression asymmeric seems like a bad warning.
Does removing the cast seem like a reasonable solution? Is there
a way for GCC to ignore the signedness of non-negative constant integers
combined with variable expressions?
Thanks, David