From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31542 invoked by alias); 29 Nov 2004 16:30:21 -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 31343 invoked from network); 29 Nov 2004 16:30:11 -0000 Received: from unknown (HELO mail2.codesourcery.com) (66.160.135.55) by sourceware.org with SMTP; 29 Nov 2004 16:30:11 -0000 Received: (qmail 2216 invoked from network); 29 Nov 2004 16:30:10 -0000 Received: from support.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.10) by mail2.codesourcery.com with SMTP; 29 Nov 2004 16:30:10 -0000 Received: (qmail 5711 invoked from network); 29 Nov 2004 16:30:09 -0000 Received: from localhost (HELO ?192.168.189.167?) (nathan@127.0.0.1) by mail.codesourcery.com with SMTP; 29 Nov 2004 16:30:09 -0000 Message-ID: <41AB4E8A.4020801@codesourcery.com> Date: Mon, 29 Nov 2004 16:33:00 -0000 From: Nathan Sidwell Organization: Codesourcery LLC User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 MIME-Version: 1.0 To: Dave Korn CC: gcc@gcc.gnu.org Subject: Re: warning: right shift count >= width of type References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-11/txt/msg01131.txt.bz2 Dave Korn wrote: > > Afternoon all. Here's something that's piqued my curiosity; it's probably > owing to some language-lawyerly issue, but it isn't obvious to me. This is > on gcc-3.3.3, (cygwin variant, but that's probably not relevant): > > -------------------------------------------------- > dk@mace /test/shift-test> cat foo.c > > unsigned int bar (unsigned int baz) > { > unsigned int quux; > > quux = baz >> 32; > return quux; > } > > dk@mace /test/shift-test> gcc -S foo.c -O2 -o foo.s > foo.c: In function `bar': > foo.c:7: warning: right shift count >= width of type > dk@mace /test/shift-test> cat foo.s > Why isn't the shift operation optimised away and replaced with const_int > 0? It's _undefined_. Didn't you make some comment about what undefined meant last week :) nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk