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: [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.

Roger
--


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