bug-gnulib
[Top][All Lists]
Advanced

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

Re: base64: gcc-15 compile issue


From: Pádraig Brady
Subject: Re: base64: gcc-15 compile issue
Date: Sat, 21 Dec 2024 20:34:18 +0000
User-agent: Mozilla Thunderbird Beta

On 21/12/2024 19:58, Jeffrey Walton wrote:
On Sat, Dec 21, 2024 at 9:45 AM Bruno Haible via Gnulib discussion
list <bug-gnulib@gnu.org> wrote:

Rudi Heitbaum wrote:
When compiling grub-2.12 with gcc-15-20241208 the following line causes
the following error:

https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/base64.c#n62

../../grub-core/lib/gnulib/base64.c:65:3:
   error: initializer-string for array of 'char' is too long
   [-Werror=unterminated-string-initialization]

    65 |   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

No, this line is not causing an error. This line causes a warning, and
it is either your use of CPPFLAGS and CFLAGS or grub's configure.ac which
adds '-Werror' and thus turns the warning into an error.

Use of -Werror with gnulib is unsupported. We cannot avoid all compiler
warnings on all systems, in particular because some warnings are style
warnings and opposite warnings exist as well.

In this case, the code is perfectly fine: it initializes an array of
size 64 with 64 characters. There is no better way to write such an
initialization.

The string literal includes the trailing NULL, so the literal is 65
chars, not 64 char.

C99 supports excluding the NUL, while C++ does not.
So this is fine IMHO and gcc shouldn't be warning about this.
Note if you use a non specific sized array, i.e. char b64c[] = "A..."
then you lose the compiler check if the literal is too long
(though there is no warning if the literal is too short).

cheers,
Pádraig



reply via email to

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