[Top][All Lists]

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

-Wvla vs dcnpgettext_expr's VLA decl

From: Jim Meyering
Subject: -Wvla vs dcnpgettext_expr's VLA decl
Date: Sat, 03 Dec 2011 17:02:01 +0100

Hi Bruno,

This is in the context of manywarnings, so I'll write to bug-gnulib,
of course, you're welcome to add bug-gettext, if desired.

I tried enabling -Wvla for coreutils and found that it provoked hundreds
of warnings, all due to this:

    ../lib/gettext.h:262:3: error: variable length array 'msg_ctxt_id'\
    is used [-Werror=vla]

That comes from this inline function from gettext.h:

    static const char *
    dcnpgettext_expr (const char *domain,
                      const char *msgctxt, const char *msgid,
                      const char *msgid_plural, unsigned long int n,
                      int category)
      size_t msgctxt_len = strlen (msgctxt) + 1;
      size_t msgid_len = strlen (msgid) + 1;
      const char *translation;
      char msg_ctxt_id[msgctxt_len + msgid_len];

Do we have a guarantee that that array dimension is reasonable?

Have you compared the trade-offs of VLA-vs-malloc here?

reply via email to

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