Bug 32072 - ./dlltool.c:870:27: error: initializer-string for array of 'char' is too long
Summary: ./dlltool.c:870:27: error: initializer-string for array of 'char' is too long
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.44 (HEAD)
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-11 20:10 UTC by Jan-Benedict Glaw
Modified: 2024-08-13 14:10 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-mingw32crt, i686-cygwin
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Benedict Glaw 2024-08-11 20:10:30 UTC
Hi!

While doing automated builds using a _very_ recent host GCC (gcc (basepoints/gcc-15-2866-g9d5c500c4fa, built at 1723293902) 15.0.0 20240810 (experimental)), I got issues with dlltool.c (for --target=i686-mingw32crt and -target=i686-cygwin):

[all 2024-08-11 18:35:01] /var/lib/laminar/run/binutils-i686-cygwin/51/local-toolchain-install/bin/gcc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include -DLOCALEDIR="\"/tmp/binutils-i686-cygwin/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I./../zlib  -g -O2   -MT dlltool.o -MD -MP -MF .deps/dlltool.Tpo -c -o dlltool.o  -DDLLTOOL_I386 -DDLLTOOL_DEFAULT_I386 ./dlltool.c
[all 2024-08-11 18:35:01] ./dlltool.c: In function 'prefix_encode':
[all 2024-08-11 18:35:01] ./dlltool.c:870:27: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
[all 2024-08-11 18:35:01]   870 |   static char alpha[26] = "abcdefghijklmnopqrstuvwxyz";
[all 2024-08-11 18:35:01]       |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[all 2024-08-11 18:35:05] cc1: all warnings being treated as errors


(See http://toolchain.lug-owl.de/laminar/jobs/binutils-i686-cygwin/51 or http://toolchain.lug-owl.de/laminar/jobs/binutils-i686-mingw32crt/51)

Should be easy to fix but dropping the explicit array length and introduce a strlen() based lenght instead of sizeof.
Comment 1 Sourceware Commits 2024-08-13 03:21:50 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cfe96ff03ac34a4cdbd257aaefdf7415652044fe

commit cfe96ff03ac34a4cdbd257aaefdf7415652044fe
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Aug 13 07:55:04 2024 +0930

    PR32072 dlltool.c initializer-string is too long
    
            PR 32072
            * dlltool.c: Delete unneeded forward function declaraions.
            Make buffers used by dlltmp static.
            (prefix_encode): Avoid warning.  Use stpcpy.
Comment 2 Alan Modra 2024-08-13 14:10:37 UTC
.