From: Guinevere Larsen Date: Mon, 8 Sep 2025 19:53:46 +0000 (-0300) Subject: gdb: fix build with newest clang X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a66526aca60c9a8ea911310e4447ad525024f241;p=thirdparty%2Fbinutils-gdb.git gdb: fix build with newest clang The upstream build of GDB can fail on fedora rawhide, since the self check in regcache.c uses an unitialized variable to be compared, which now generates the following warning: binutils-gdb/gdb/regcache.c:1847:42: error: variable 'buf' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer] 1847 | SELF_CHECK (regcache->raw_compare (0, &buf, register_size (inf.arch (), 0))); This commit fixes that by initializing the variable to 0. Since the comment above that line would be changed, it was also reformatted so that it doesn't go beyond 80 columns. Approved-By: Simon Marchi --- diff --git a/gdb/regcache.c b/gdb/regcache.c index 9892c54ba12..cf4c5dd7b7c 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1841,9 +1841,10 @@ reg_buffer_raw_compare_zero_len_test () const regcache *regcache = get_thread_arch_regcache (&inf, ptid_t (1, 1), inf.arch ()); - /* The buffer address is irrelevant since we end up comparing 0 bytes, we just - need to pass something. */ - gdb_byte buf; + /* The buffer address is irrelevant since we end up comparing 0 bytes, we + just need to pass something. The variable needs to be initialized to + avoid compiler warnings about uninitialized values. */ + gdb_byte buf = 0; SELF_CHECK (regcache->raw_compare (0, &buf, register_size (inf.arch (), 0))); }