[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.207,2.208

Fred L. Drake, Jr. fdrake@beopen.com
Wed, 11 Oct 2000 09:42:57 -0400 (EDT)

Tim Peters writes:
 > Update of /cvsroot/python/python/dist/src/Python
 > Attempt to fix bogus gcc -Wall warnings reported by Marc-Andre Lemburg,
 > by making the DUP_TOPX code utterly straightforward.  This also gets rid
 > of all normal-case internal DUP_TOPX if/branches, and allows replacing one
 > POP() with TOP() in each case, so is a good idea regardless.

  There's still one left:

gcc -Wall -O2 -Wstrict-prototypes -I../../Python/../Include -I.. -DHAVE_CONFIG_H   -c -o ceval.o ../../Python/ceval.c
../../Python/ceval.c: In function `eval_code2':
../../Python/ceval.c:346: warning: `w' might be used uninitialized in
this function

  Cruising through this code, it looks like the problem might be in

			if (stream == NULL || stream == Py_None) {
				w = PySys_GetObject("stdout");
				if (w == NULL)
							"lost sys.stdout");
			if (w != NULL) {
	/* If PRINT_NEWLINE is the opcode, w might not be initialized
         * here (I think), since I don't see it initialize before the
         * switch.  Since we can't initialize it to NULL with the case
         * (doing so would break the PRINT_NEWLINE_TO case), it would
         * have to be initialized before the main loop is entered.
				err = PyFile_WriteString("\n", w);
				if (err == 0)
					PyFile_SoftSpace(w, 0);
			stream = NULL;

  Ok.... yep, initializing that seems to work.
  I'll check in the fix for this one after I've run the regression test.


Fred L. Drake, Jr.  <fdrake at beopen.com>
BeOpen PythonLabs Team Member