Subject: bug#8512: possibly uninitialized variable in x_produce_glyphs

From: Eli Zaretskii <[email-masked]>
Date: Sun, 17 Apr 2011 00:24:32 +0300

> Date: Sat, 16 Apr 2011 12:40:36 -0700
> From: Paul Eggert <[email-masked]>
> 
> In the Emacs trunk, GCC 3.4.3 on Solaris 10 warns about a possibly uninitialized
> variable in x_produce_glyphs, and it's not clear to me that this diagnostic is
> wrong.  The function assumes that cmp->glyph_len > 0, but a quick look through the
> rest of Emacs suggests that it's possible that it's zero.  To play it safe
> until someone with more expertise about glyphs can look at the problem, I plan
> to install this patch:
> 
> --- src/xdisp.c	2011-04-16 01:54:37 +0000
> +++ src/xdisp.c	2011-04-16 19:24:11 +0000
> @@ -22712,7 +22712,7 @@ x_produce_glyphs (struct it *it)
>  	  int lbearing, rbearing;
>  	  int i, width, ascent, descent;
>  	  int left_padded = 0, right_padded = 0;
> -	  int c;
> +	  int c = 0; /* FIXME: Is 0 right here, when cmp->glyph_len == 0?  */

I don't think it matters how you initialize c here, because
cmp->glyph_len can never be zero there.  However, using c=0 here is
not right, I think; I would use a printable character, like ' ' or
something, so that get_char_face_and_encoding gets a real character to
play with.