[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#51075: 29.0.50; Uninitialised variable warning in src/term.c
From: |
Eli Zaretskii |
Subject: |
bug#51075: 29.0.50; Uninitialised variable warning in src/term.c |
Date: |
Thu, 07 Oct 2021 16:01:58 +0300 |
> Cc: Paul Eggert <eggert@cs.ucla.edu>
> Date: Thu, 07 Oct 2021 12:18:14 +0100
> From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> I'm currently seeing the following warning with GCC 10.3.0:
>
> In file included from term.c:30:
> term.c: In function ‘encode_terminal_code’:
> lisp.h:1853:35: warning: ‘gstring’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
> 1853 | return XVECTOR (array)->contents[idx];
> | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> term.c:553:16: note: ‘gstring’ was declared here
> 553 | Lisp_Object gstring;
> | ^~~~~~~
It's a bogus warning. It might be worth reporting to the GCC folks
(unless GCC 11 already fixed that).
> Is
>
> cmp = composition_table[src->u.cmp.id];
>
> indeed guaranteed to be non-NULL?
If it's ever NULL, the very next line will segfault:
cmp = composition_table[src->u.cmp.id];
required = cmp->glyph_len;
> If so, maybe gstring could be
> initialised as nil and then easserted as non-nil in the !cmp branch
> (eassuming cmp is non-NULL in the !src->u.cmp.automatic branch does not
> make the warning go away). If not, could there indeed be a bug?
Feel free to assign some value to gstring in the 'else' clause, to
shut up GCC in this case.