This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
- From: "Al Grant" <AlGrant at myrealbox dot com>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 12 Jul 2002 15:06:01 -0000
- Subject: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
- Reply-to: "Al Grant" <AlGrant at myrealbox dot com>
The following reply was made to PR c/7284; it has been noted by GNATS.
From: "Al Grant" <AlGrant@myrealbox.com>
To: nathan@gcc.gnu.org,
algrant@acm.org,
gcc-bugs@gcc.gnu.org,
gcc-prs@gcc.gnu.org,
nobody@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
Date: Fri, 12 Jul 2002 15:00:34 +0000
On 12/07/2002 15:12:01 nathan wrote:
>Synopsis: incorrectly simplifies leftshift followed by signed power-of-2
>division
>
>State-Changed-From-To: open->closed
>State-Changed-By: nathan
>State-Changed-When: Fri Jul 12 07:12:01 2002
>State-Changed-Why:
>not a bug. for signed types, if 'n << c' overflows, the
>behaviour is undefined.
There is no "overflow" in my sample code. The operation of shifting 128 24=
bits to the left on a
32-bit machine produces the bit pattern 0x80000000.
No bits overflow.
The fact that a positive number may become negative when left-shifted is a =
property of the twos complement representation. The standard does not de=
fine signed left shift in terms of multiplication and certainly doesn't s=
ay that it is undefined when the apparently equivalent multiplication wou=
ld be undefined.