diff options
author | Tsukasa OI <research_trasio@irq.a4lg.com> | 2022-10-28 06:46:13 +0000 |
---|---|---|
committer | Tsukasa OI <research_trasio@irq.a4lg.com> | 2022-10-28 07:45:25 +0000 |
commit | 615d4f4133703111b893b6a4d175250dfa4f630b (patch) | |
tree | 3221b4f01278add4634768d646284979a064c83f /gas | |
parent | d9757bcd43534875d2003962944d3d130289f82c (diff) | |
download | gdb-615d4f4133703111b893b6a4d175250dfa4f630b.zip gdb-615d4f4133703111b893b6a4d175250dfa4f630b.tar.gz gdb-615d4f4133703111b893b6a4d175250dfa4f630b.tar.bz2 |
RISC-V: Fix build failure for -Werror=maybe-uninitialized
Commit 40f1a1a4564b ("RISC-V: Output mapping symbols with ISA string.")
caused a build failure on GCC 12 as follows:
make[3]: Entering directory '$(builddir)/gas'
CC config/tc-riscv.o
In file included from $(srcdir)/gas/config/tc-riscv.c:23:
$(srcdir)/gas/as.h: In function ‘make_mapping_symbol’:
$(srcdir)/gas/as.h:123:15: error: ‘buff’ may be used uninitialized [-Werror=maybe-uninitialized]
123 | #define xfree free
| ^~~~
$(srcdir)/gas/config/tc-riscv.c:487:9: note: ‘buff’ was declared here
487 | char *buff;
| ^~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:1425: config/tc-riscv.o] Error 1
This is caused by a false positive of "maybe uninitialized" variable
detection (-Wmaybe-uninitialized). To avoid this error, this commit
initializes the local variable buff to NULL first in all cases.
gas/ChangeLog:
* config/tc-riscv.c (make_mapping_symbol): Initialize variable
buff with NULL to avoid build failure caused by a GCC's false
positive of maybe uninitialized variable detection.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-riscv.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 91cff7d..f4478ea 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -484,7 +484,7 @@ make_mapping_symbol (enum riscv_seg_mstate state, bool reset_seg_arch_str) { const char *name; - char *buff; + char *buff = NULL; switch (state) { case MAP_DATA: |