Subject: bug#9948: valgrind warning: Conditional jump or move depends on uninitialised value(s) in redisplay_window

From: Paul Eggert <[email-masked]>
Date: Sun, 06 Nov 2011 21:04:40 -0800

--track-origins=yes should help, but in the meantime, valgrind's
bug report doesn't necessarily mean that no code ever set scrolling_up.

It could be that scrolling_up was set this way:

      scrolling_up = PT > margin_pos;

but that margin_pos wasn't properly initialized.  For example, suppose
margin_pos was set this way:

          margin_pos = IT_CHARPOS (it1);

This initialization would not be correct if IT_CHARPOS (it1) referenced
an uninitialized variable.

Unfortunately valgrind won't report any error in IT_CHARPOS (it1)
until scrolling_up is used.  That's because it does not report use
of uninitialized storage: it reports only when conditional branches
or syscalls or addresses depend on the contents of the uninitialized
storage.

It's too bad that valgrind works this way.  It'd be more convenient if it
reported use of uninitialized storage right away.  But it'd be hard for
valgrind to do better, without reporting lots of false positives for
structures that contain holes, so it is what it is.