GNU bug report logs - #51075
29.0.50; Uninitialised variable warning in src/term.c

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Thu, 7 Oct 2021 11:19:01 UTC

Severity: minor

Found in version 29.0.50

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 51075 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 51075 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: 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 <at> 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 <at> 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.




This bug report was last modified 3 years and 305 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.