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: rearnsha at gcc dot gnu dot org
- To: algrant at acm dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 13 Feb 2003 16:06:23 -0000
- Subject: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
- Reply-to: rearnsha at gcc dot gnu dot org, algrant at acm dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: incorrectly simplifies leftshift followed by signed power-of-2 division
State-Changed-From-To: closed->open
State-Changed-By: rearnsha
State-Changed-When: Thu Feb 13 16:06:23 2003
State-Changed-Why:
I'm re-opening this report. In c89 the text for << says
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros.
It then goes on to qualify what this means when E1 is unsigned, but says nothing about the *interpretation* for the signed context (beyond what is specified above). However, in a 2s complement environment it is possible to give a meaningful interpretation of the resulting value.
DR#081 says that the meaning in the signed context is "implementation defined", but that is clearly very different from "undefined" as we have at present.
At the very least we must document what left shift of a signed value means on our implementation.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7284