From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31580 invoked by alias); 12 Jul 2002 16:56:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31566 invoked by uid 71); 12 Jul 2002 16:56:00 -0000 Date: Fri, 12 Jul 2002 09:56:00 -0000 Message-ID: <20020712165600.31565.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Al Grant" Subject: Re: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division Reply-To: "Al Grant" X-SW-Source: 2002-07/txt/msg00382.txt.bz2 List-Id: The following reply was made to PR c/7284; it has been noted by GNATS. From: "Al Grant" To: falk.hueffner@student.uni-tuebingen.de Cc: 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 Subject: Re: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division Date: Fri, 12 Jul 2002 16:50:21 +0000 >Right, I just assumed it to be very unlikely that this was changed to >be undefined in C99.=20 So did I, otherwise I would have checked it! >I don't have the C89 standard; could you perhaps >cite the passage that shows this was defined >behaviour in C89? 3.3.7 (something else in ISO, maybe 6.3.7) The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. It then goes on to say "If E1 has an unsigned type..." and notes that it is= equivalent to a multiplication. For signed types it says nothing more. Now if signed left-shift is defined at all, in terms of the representation, I don't see there's any lack of definition in "0x000= 00080 left-shifted 24 bit positions", it is clearly 0x80000000 (of the sa= me type). So it's defined unless the standard says otherwise, which only= C99 seems to. There's no reason given to treat it specially if it happens to represent a = negative signed number. This is not a case of an ideal signed arithmetic= operation producing some result in the ideal integers that cannot be rep= resented in the particular signed type, so the undefinedness in that case= doesn't apply here.