From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS11232 140.186.0.0/16 X-Spam-Status: No, score=-2.2 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Qfq7a-0004pe-Ia for mharc-bug-gnulib@gnu.org; Sun, 10 Jul 2011 05:16:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfq7X-0004pX-8L for bug-gnulib@gnu.org; Sun, 10 Jul 2011 05:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qfq7V-00038q-Lx for bug-gnulib@gnu.org; Sun, 10 Jul 2011 05:16:11 -0400 Received: from mail-vw0-f41.google.com ([209.85.212.41]:53683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfq7V-00038l-F9 for bug-gnulib@gnu.org; Sun, 10 Jul 2011 05:16:09 -0400 Received: by vws4 with SMTP id 4so2787735vws.0 for ; Sun, 10 Jul 2011 02:16:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.175.230 with SMTP id cd6mr1172787vdc.456.1310289366889; Sun, 10 Jul 2011 02:16:06 -0700 (PDT) Received: by 10.52.158.197 with HTTP; Sun, 10 Jul 2011 02:16:06 -0700 (PDT) In-Reply-To: <4E192EFE.4020608@cs.ucla.edu> References: <4E192EFE.4020608@cs.ucla.edu> Date: Sun, 10 Jul 2011 10:16:06 +0100 Message-ID: Subject: Re: Correct but unhelpful VLA warning vs. gnulib's gettext.h; can we eliminate the false positive? From: James Youngman To: Paul Eggert Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.41 Cc: bug-gnulib X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jul 2011 09:16:12 -0000 On Sun, Jul 10, 2011 at 5:47 AM, Paul Eggert wrote: > On 07/09/11 15:32, James Youngman wrote: >> Is there a way of eliminating this false positive which doesn't force >> me to give up -Wvla? > > You can use a pragma in the module that you've audited. > The pragma would tell GCC, "don't waste my time warning > about VLAs in this module". I can't see a way of making this strategy conveniently work, since there the VLA is in gettext.h, which will be included by a number of source files. Adding #pragma GCC ignored -Wvla to gettexzt.h would result in VLA warnings being suppressed for any module which uses gettext.h, which is one of the things I was trying to avoid. While I could balance this by remembering to put #pragma GCC warning -Wvla in my source files after all the includes, it seems to me I'm no more likely to remember to do that than to avoid using VLAs in the first place. This would also take away from the user the configure-time control they currently have over what warning flags are turned on or off. Something I haven't tried yet it a configure.ac change; if we discover in configure that -Wvla is in CFLAGS and the compiler is GCC, we could add this: #pragma GCC diagnostic error "-Wvla" ... presumably if done correctly this would cause configure to set _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS to 0. This method seems suboptimal to me though, since as I mentioned earlier in the thread, the ideal thing would be to allow VLAs in parts of the code which are protected by something like _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS. A function-level pragma would probably be ideal here, but unfortunately they can only be used to tweak optimisation and function attributes. James.