From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27254 invoked by alias); 16 Oct 2002 00:49:35 -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 27243 invoked from network); 16 Oct 2002 00:49:34 -0000 Received: from unknown (HELO egil.codesourcery.com) (66.92.14.122) by sources.redhat.com with SMTP; 16 Oct 2002 00:49:34 -0000 Received: from zack by egil.codesourcery.com with local (Exim 3.36 #1 (Debian)) id 181cNN-0007Mn-00; Tue, 15 Oct 2002 17:49:29 -0700 Date: Tue, 15 Oct 2002 19:15:00 -0000 From: Zack Weinberg To: Michael Matz Cc: Jamie Lokier , Kevin Lawton , gcc@gcc.gnu.org Subject: Re: Request of new __attribute__ for switch statements (elimination of the bounds check) Message-ID: <20021016004929.GO15067@codesourcery.com> References: <20021015032827.GA15067@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-SW-Source: 2002-10/txt/msg00907.txt.bz2 On Tue, Oct 15, 2002 at 04:32:34PM +0200, Michael Matz wrote: > Well, if you have data corruption, hmm, well, you're screwed ;-) The same > happens, when you access a pointer retrieved from corrupted memory. Sure. The question is how _soon_ you will be screwed to the point that the program crashes. Ideally this happens as soon after the actual data corruption event as possible. (If I had a nickel for every time I've wanted a "step backward" command in gdb...) > > This does not mean that your idea is a bad one; the attribute could be > > used for stricter type checking and more effective warnings, which is > > a good thing. I just don't like the idea of using it to optimize out > > bounds checks. > > Why not? Possibility for data corruption is no argument for not doing > things. Remember also, that there are other syntactic means to enable > certain optimizations, 'restrict' or __builtin_expect for example. It's just that I see removing the bounds checks on a switch statement as a marginal optimization compared to the risk. I've never seen a switch be the bottleneck in anything. Your mileage may vary. zw