unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8290: possibly-uninitialized variables in find_automatic_composition
@ 2011-03-19  2:12 Paul Eggert
  2011-05-19  1:32 ` bug#8697: " handa
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Eggert @ 2011-03-19  2:12 UTC (permalink / raw)
  To: 8290

Severity: minor

In the Emacs trunk, src/composite.c's find_automatic_composition has
two local variables 'check' and 'prev' that gcc -Wuninitialized warns
as being possibly being uninitialized when used.  This function has
multiple gotos and dependencies on data structures that I don't
understand, so it's not clear to me that GCC is wrong here.  So I'm
filing a bug report in the hopes that someone more expert can look at it.

I plan to work around the diagnostic by committing the following
change, which adds a FIXME comment asking for initial value if needed,
and for the comment to be removed if the code is OK as-is.  IF_LINT
is used to tell GCC not to issue a warning here, for now.

I'm CC:ing this to Kenichi Handa, who committed the code in question,
to give him a heads-up about the problem.


* composite.c (find_automatic_composition): Mark vars as initialized, with a FIXME.
=== modified file 'src/composite.c'
--- src/composite.c	2011-03-19 00:58:10 +0000
+++ src/composite.c	2011-03-19 01:02:12 +0000
@@ -1489,7 +1489,13 @@
   EMACS_INT head, tail, stop;
   /* Limit to check a composition after POS.  */
   EMACS_INT fore_check_limit;
-  struct position_record orig, cur, check, prev;
+  struct position_record orig, cur;
+
+  /* FIXME: It's not obvious whether these two variables need initialization.
+     If they do, please supply initial values.
+     If not, please remove this comment.  */
+  struct position_record check IF_LINT (= {0}), prev IF_LINT (= {0});
+
   Lisp_Object check_val, val, elt;
   int c;
   Lisp_Object window;






^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#8697: possibly-uninitialized variables in find_automatic_composition
  2011-03-19  2:12 bug#8290: possibly-uninitialized variables in find_automatic_composition Paul Eggert
@ 2011-05-19  1:32 ` handa
  0 siblings, 0 replies; 2+ messages in thread
From: handa @ 2011-05-19  1:32 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 8697

Very sorry for the late response on this matter.

In article <4D841112.50403@cs.ucla.edu>, Paul Eggert <eggert@cs.ucla.edu> writes:

> In the Emacs trunk, src/composite.c's find_automatic_composition has
> two local variables 'check' and 'prev' that gcc -Wuninitialized warns
> as being possibly being uninitialized when used.  This function has
> multiple gotos and dependencies on data structures that I don't
> understand, so it's not clear to me that GCC is wrong here.  So I'm
> filing a bug report in the hopes that someone more expert can look at it.

> I plan to work around the diagnostic by committing the following
> change, which adds a FIXME comment asking for initial value if needed,
> and for the comment to be removed if the code is OK as-is.  IF_LINT
> is used to tell GCC not to issue a warning here, for now.

> I'm CC:ing this to Kenichi Handa, who committed the code in question,
> to give him a heads-up about the problem.

Actually, those local variables are surely initialized when
used.  But as they are initialized under a specific
condition (e.g. check_val is set to non-nil) and used under
the same condition, it's difficult for gcc to detect that.

Anyway, I've just committed an inproved version of
find_automatic_composition, and gcc won't complain about it
now.

2011-05-18  Kenichi Handa  <handa@m17n.org>

	* composite.c (CHAR_COMPOSABLE_P): Add more check for efficiency.
	(BACKWARD_CHAR): Wrap the arg STOP by parenthesis.
	(find_automatic_composition): Mostly rewrite for efficiency.

---
Kenichi Handa
handa@m17n.org





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-19  1:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-19  2:12 bug#8290: possibly-uninitialized variables in find_automatic_composition Paul Eggert
2011-05-19  1:32 ` bug#8697: " handa

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).