bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct but unhelpful VLA warning vs. gnulib's gettext.h; can we eli


From: James Youngman
Subject: Re: Correct but unhelpful VLA warning vs. gnulib's gettext.h; can we eliminate the false positive?
Date: Sun, 10 Jul 2011 10:16:06 +0100

On Sun, Jul 10, 2011 at 5:47 AM, Paul Eggert <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]