From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12926 invoked by alias); 29 Nov 2004 19:19:58 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 12867 invoked from network); 29 Nov 2004 19:19:51 -0000 Received: from unknown (HELO NUTMEG.CAM.ARTIMI.COM) (217.40.111.177) by sourceware.org with SMTP; 29 Nov 2004 19:19:51 -0000 Received: from mace ([192.168.1.25]) by NUTMEG.CAM.ARTIMI.COM with Microsoft SMTPSVC(6.0.3790.211); Mon, 29 Nov 2004 19:18:25 +0000 From: "Dave Korn" To: "'Dale Johannesen'" , "'Andrew Haley'" Cc: , "'Nathan Sidwell'" Subject: RE: warning: right shift count >= width of type Date: Mon, 29 Nov 2004 19:54:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <7B08DB42-4238-11D9-BDCE-000A95D7CD40@apple.com> Message-ID: X-OriginalArrivalTime: 29 Nov 2004 19:18:25.0375 (UTC) FILETIME=[32EF4EF0:01C4D648] X-SW-Source: 2004-11/txt/msg01156.txt.bz2 > -----Original Message----- > From: Dale Johannesen > Sent: 29 November 2004 18:57 > On Nov 29, 2004, at 10:51 AM, Andrew Haley wrote: > >> I myself would want "(n >> 32)" to produce the same > result as "((n > >> >> 16) > >>>> 16)" and indeed "for (int i = 32; i > 0; i--, n >>= 1) > ;", and it > >>>> seems > >> to be generally agreed that the compiler would be at > liberty to so do > >> if it > >> wants to. > > > > But you could never depend on it. If it only works when the shift > > count is a constant, a failure to do constant folding would > break it. > > Or constant propagation, or inlining, or ... > Ah. Good point. Of course, in such cases, the compiler will also fail to produce the warning message too....... cheers, DaveK -- Can't think of a witty .sigline today....