Subject: bug#24424: Emacs fails to build with --enable-gcc-warnings on gcc 4.8.4

From: Eli Zaretskii <[email-masked]>
Date: Tue, 13 Sep 2016 17:26:55 +0300

tags 24424 + notabug
thanks

> From: Michal Nazarewicz <[email-masked]>
> Date: Mon, 12 Sep 2016 22:54:11 +0200
> 
> Building with --enable-gcc-warnings results in:
> 
> CC       bidi.o
> bidi.c: In function ‘bidi_find_bracket_pairs’:
> bidi.c:2765:38: error: ‘pairing_pos’ may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> bidi_it->next_for_neutral.charpos = pairing_pos;
> ^
> cc1: all warnings being treated as errors
> 
> $ gcc --version
> gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
> 
> Cursory look at the function did not reveal obvious solution.

I don't see this warning on my system, with GCC 5.3.  I suggest to
upgrade your GCC version, or omit this switch from the command line.
Paul will correct me if I'm wrong, but IME these paranoid warning
switches are only usable with GCC 5 (or maybe 4.9) and later, and
yield too many false positives with earlier versions.

There's nothing wrong with the code in that function.  Its 'while (1)'
loop can only be exited via one of the 2 'break' statements.  The
former of these two exits assigns 'true' to 'retval', the 2nd gives a
value to 'pairing_pos':

	  if (type == NEUTRAL_B
	      || (bidi_it->level_stack[bidi_it->stack_idx].level
		  != current_level))
	    {
	      /* We've marched all the way to the end of this
		 isolating run sequence, and didn't find matching
		 closing brackets for some opening brackets.  Leave
		 their type unchanged.  */
	      pairing_pos = bidi_it->charpos;
	      break;
	    }

In the former case, 'pairing_pos' gets its value after the loop:

	  if (retval)
	    pairing_pos = bidi_it->bracket_pairing_pos;

(The 'while (1)' loop can also be exited via 'goto give_up', but in
that case the value of 'pairing_pos' is not used at all.)