From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10033 invoked by alias); 20 Apr 2003 18:44:46 -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 10026 invoked from network); 20 Apr 2003 18:44:46 -0000 Received: from unknown (HELO fencepost.gnu.org) (199.232.76.164) by sources.redhat.com with SMTP; 20 Apr 2003 18:44:46 -0000 Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.10) id 197Jny-0000eI-00 for gcc@gnu.org; Sun, 20 Apr 2003 14:44:46 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 197Jni-0003GQ-00 for gcc@gnu.org; Sun, 20 Apr 2003 14:44:30 -0400 Received: from vsmtp3.tin.it ([212.216.176.223] helo=smtp3.cp.tin.it) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 197JnR-0002OJ-00 for gcc@gnu.org; Sun, 20 Apr 2003 14:44:13 -0400 Received: from unitus.it (80.181.224.125) by smtp3.cp.tin.it (6.7.016) id 3E8D7402005D2A44; Sun, 20 Apr 2003 20:44:04 +0200 Message-ID: <3EA2EAB5.3040101@unitus.it> Date: Mon, 21 Apr 2003 02:21:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030401 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gp.bolton@computer.org CC: gcc Subject: Const warning? (was: Re: [Patch] More redundant...) References: <3EA18026.70900@unitus.it> <3EA1B709.3060204@free.fr> In-Reply-To: <3EA1B709.3060204@free.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-8.4 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, RCVD_IN_MULTIHOP_DSBL,RCVD_IN_UNCONFIRMED_DSBL,REFERENCES, SPAM_PHRASE_01_02,USER_AGENT,USER_AGENT_MOZILLA_UA, X_ACCEPT_LANG version=2.41 X-Spam-Level: X-SW-Source: 2003-04/txt/msg00966.txt.bz2 [discussion moved to gcc] Gawain Bolton wrote: > These patches to add "const" make me wonder if the compiler couldn't > help us. > > I thinking about a warning for variables which the compiler can see > are not modified. Something like: > > Warning: Variable x should be const. > > Is this possible? Could this be useful? Hi Gawain (by the way those patches mainly remove some NULL pointer checks, only secondarily const-ify variables). I find your question interesting: as for many other warnings of this kind (unreachable code, uninitialized variables, and so on) how many such warnings would be missed or spuriously emitted would constitute a good testbed for the optimizers of the compiler. Ideally the code generated would be identical with and without const qualifiers but we all know that in the real world this is not the case! Ideas from the compiler people??? Paolo.