This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c/6677 and al.
- From: Richard Henderson <rth at redhat dot com>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 May 2002 17:48:03 -0700
- Subject: Re: PR c/6677 and al.
- References: <00fa01c206a2$9759ab60$1f0e81d4@zephyr>
On Wed, May 29, 2002 at 01:50:50AM +0200, Eric Botcazou wrote:
> j = ((char) (i << 1)) / 2;
[...]
> The proposed fix is to disallow the second transformation when the type is
> signed and the global operation not a MULT_EXPR.
This isn't the best thing, since we _are_ allowed to produce the screwey
result with "int" instead of char. The reason this expression is valid
is that the arithmetic is all done in "int", not "char", and the
expression does not overflow as an int.
And indeed, it would appear that your other problem
> j = ((char) (i * 2)) / 2;
is the same root problem. We can't look through the narrowing cast as
readily as we're doing.
r~