From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1156 invoked by alias); 16 Oct 2002 19:06: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 1148 invoked from network); 16 Oct 2002 19:06:33 -0000 Received: from unknown (HELO mx04.nexgo.de) (151.189.8.80) by sources.redhat.com with SMTP; 16 Oct 2002 19:06:33 -0000 Received: from Hartmut (dialin-145-254-036-044.arcor-ip.net [145.254.36.44]) by mx04.nexgo.de (Postfix) with SMTP id D394337BA9; Wed, 16 Oct 2002 21:06:30 +0200 (CEST) Message-ID: <00cb01c27547$263cecd0$2c24fe91@Hartmut> From: "Hartmut Schirmer" To: , "Kevin Lawton" Cc: "Zack Weinberg" , "Michael Matz" , "Jamie Lokier" , References: <20021016004929.GO15067@codesourcery.com> <20021016013810.22926.qmail@web80304.mail.yahoo.com> <20021015191724.A21405@hollebeek.com> Subject: Re: Request of new __attribute__ for switch statements (elimination of the bounds check) Date: Wed, 16 Oct 2002 13:27:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2002-10/txt/msg00989.txt.bz2 > "Tim Hollebeek" wrote: > On Tue, Oct 15, 2002 at 06:38:10PM -0700, Kevin Lawton wrote: > > > > --- Zack Weinberg wrote: > > > > > 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. > > > [snip] > > > > If we wanted to stop people from shooting theirselves > > in the feet, we wouldn't allow them to use C. At > > any rate, sometimes it's even possible to prove the > > case targets are populated: > > > > switch (a & 0x3) { > > then ask for the compiler to understand and DTRT with this syntax, > instead of some funky attribute. > > Sure, recognizing "switch ((expr) & (integral constant 2^n-1))" only > works for tables that are powers of two, but I suspect that would > already go quite a ways towards what many people need. Other nice things to have: - warn about unreachable case values - removed unreachable code gcc need not be perfect on this. Just checking easy available properties of the switch value would be a great help. Hartmut