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: PR c/6677 and al.


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~


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