[gnu.gdb.bug] && bug

tiemann@LURCH.STANFORD.EDU (Michael Tiemann) (11/20/89)

   Date: Sun, 19 Nov 89 15:36:34 PST
   From: raulmill%aludra.usc.edu@usc.edu (Raul Deluth Rockwell)

   Code:
	   a->Rest_Length = t	/* refigure length count */
	       && 1 + a->Rest->Rest_Length;

   Code purpose: If t is a null pointer, count is zero, otherwise count
   indicates list length.

   Problem: works fine for generating a->Rest_Length = 0 or
   a->Rest_Length = 1, won't make a->Rest_Length = 2.

   Types:
   struct arg_list_struct {
       unsigned Line;
       char * Source;
       union {
	   signed short Integer;
	   unsigned Coord;
	   struct arg_list_struct * List;
	   char * String;
	   struct sym_struct * Sym;
       } Arg;
       arg_type_t Arg_Type;        /* an enum */
       struct arg_list_struct * Rest;
       unsigned Rest_Length;
   } *a, *t;

   compiler version: gcc version 1.36
   compiler options: -g -sun4

   environment: Sun-4/260 with 32 MB of memory, running SunOS Release 4.0.3-GFX

   steps taken to verify presence of compiler problem rather than user
   problem: ran offending computation through gdb (gdb gave 2 where
   compiled code gave 1).

   Raul Rockwell
   INTERNET:   raulmill@usc.edu                       !
   UUCP:       ...uunet!usc!raulmill                  !  55 mph = 82 nc
   U.S.SNAIL:  721 E Windsor #4,  GLENDALE CA  91205  !

This is pilot error: the result of an && expression always evaluates
to 0 or 1.  Since GCC is right and GDB is wrong, it is a GDB bug.

To Raul, this is what you want:

   Code:
	   /* refigure length count */
	   a->Rest_Length = (t ? 1 + a->Rest->Rest_Length : 0);

   Code purpose: If t is a null pointer, count is zero, otherwise count
   indicates list length.

Michael