This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix ICE in fold-const.c
- From: Roger Sayle <roger at eyesopen dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 16 May 2004 19:59:03 -0600 (MDT)
- Subject: Re: [PATCH] Fix ICE in fold-const.c
On Sun, 16 May 2004, Andrew Pinski wrote:
> I do not have a testcase for this patch as it cannot happen in C or
> C++ or Java as you convert the (bool)(a) into a != 0.
> The ICE can happens when !(bool)a is passed to fold because fold will
> use STRIP_SIGNED_NOPS which removes the cast to bool which causes an
> ICE in invert_truthvalue.
Could you provide some more details? Firstly, if correctly written
front-ends (such as C, C++ or Java) make the conversion explicit,
which language front-end is it that needs to be fixed :>
Secondly, which ICE in invert_truthvalue is getting tripped. The
STRIP_SIGNED_NOPS macro does precisely that, remove no-op casts
that don't affect the value/mode of the argument only the type.
Hence what is it about "a" in "!(bool)a" that's triggering the ICE
if "(bool)" is a no-op cast?
A cast to bool can't be a NOP_EXPR if it's argument isn't guaranteed
to be one or zero valued. Which is why C, C++ and Java go the safe
route of making the "!= 0" explicit, which will then be removed by
fold if it can determine that the argument really is zero/one valued.
Clearly one of the invariants required by the middle-end's constant
folder isn't being satisfied and without more information, it's
difficult to determine if your proposed patch is the correct fix.