This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: More front end type mismatch problems
- From: Ian Lance Taylor <ian at airs dot com>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: gcc at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>
- Date: 27 May 2005 14:23:02 -0400
- Subject: Re: More front end type mismatch problems
- References: <20050527180545.GA8369@topo.toronto.redhat.com>
Diego Novillo <dnovillo@redhat.com> writes:
> This is happening in gcc.dg/tree-ssa/20040121-1.c. The test
> specifically tests that (p!=0) + (q!=0) should be computed as
> int:
>
> char *foo(char *p, char *q) {
> int x = (p !=0) + (q != 0);
> ...
> }
>
...
> When we call int_const_binop to fold 'true' + 'true' it returns
> 'false', and so we end up with the range [0, 0] for x_12, which
> causes the test to fail.
>
> I don't know who's at fault here. VRP is doing exactly what the
> IL tells it to. Is this program legal C? Or should the FE emit
> casts to int here?
The program is legal C. The _Bool values should be promoted to int
before doing the addition. I guess that type cast is being lost
somewhere.
Ian