RE: Expectations for 0/0

2015-07-29 Thread Paulo Matos


> -Original Message-
> From: gcc-ow...@gcc.gnu.org [mailto:gcc-ow...@gcc.gnu.org] On Behalf
> Of Paulo Matos
> Sent: 29 July 2015 10:12
> To: Andrew Haley; gcc@gcc.gnu.org
> Subject: RE: Expectations for 0/0
> 
> 
> 
> > -Original Message-
> > From: Andrew Haley [mailto:a...@redhat.com]
> > Sent: 28 July 2015 18:38
> > To: Paulo Matos; gcc@gcc.gnu.org
> > Subject: Re: Expectations for 0/0
> >
> > On 07/28/2015 04:40 PM, Paulo Matos wrote:
> > > The block skips the test for ((unsigned int) xx << 1 == 0 && yy ==
> -
> > 1), should we skip it if they're both zero as well?
> >
> > Yes.  It's undefined behaviour.  If we don't want to invoke nasal
> > daemons we shouldn't do this.
> 
> 
> Thanks. I will propose a patch to avoid this.
> 

My mistake. The check is already in the test but as I simplified the test, I 
ended up removing the check for 0 in the denominator.

Apologies.

-- 
Paulo Matos


RE: Expectations for 0/0

2015-07-29 Thread Paulo Matos


> -Original Message-
> From: Andrew Haley [mailto:a...@redhat.com]
> Sent: 28 July 2015 18:38
> To: Paulo Matos; gcc@gcc.gnu.org
> Subject: Re: Expectations for 0/0
> 
> On 07/28/2015 04:40 PM, Paulo Matos wrote:
> > The block skips the test for ((unsigned int) xx << 1 == 0 && yy == -
> 1), should we skip it if they're both zero as well?
> 
> Yes.  It's undefined behaviour.  If we don't want to invoke nasal
> daemons we shouldn't do this.


Thanks. I will propose a patch to avoid this.

-- 
Paulo Matos


Re: Expectations for 0/0

2015-07-28 Thread Andrew Haley
On 07/28/2015 04:40 PM, Paulo Matos wrote:
> The block skips the test for ((unsigned int) xx << 1 == 0 && yy == -1), 
> should we skip it if they're both zero as well?

Yes.  It's undefined behaviour.  If we don't want to invoke nasal
daemons we shouldn't do this.

Andrew.



Expectations for 0/0

2015-07-28 Thread Paulo Matos
Hi,

What are the expectations for the 0/0 division?
Test execute.exp=arith-rand.c generates two integers, both being 0 and one of 
the testing blocks is:
  { signed int xx = x, yy = y, r1, r2;
if ((unsigned int) xx << 1 == 0 && yy == -1)
  continue;
r1 = xx / yy;
r2 = xx % yy;
if (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) 
!= xx)
  abort ();
  }

Our routine returns : 
R1: 0x
R2: 0xf

Then it aborts because ABS (r2) >= (unsigned int) ABS (yy).
While I understand the results from our division routine might be peculiar, 
this division is also undefined.

The block skips the test for ((unsigned int) xx << 1 == 0 && yy == -1), should 
we skip it if they're both zero as well? If not, what do you expect to get from 
0/0 and 0%0?

Regards,

Paulo Matos