[gnu.gdb.bug] error in parsing C expression

how@IRIS.UCDAVIS.EDU (W. Wilson Ho) (10/11/88)

Version, system, etc.:

	Gdb version 2.7 running under Ultrix 2.2 on a Vax 8600.

Problem:

	Consider the following script:

how@iris:62> gdb
GDB 2.6, Copyright (C) 1988 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Type "help" for a list of commands.
(gdb) printf "%f\n", 3+(4.0-
Invalid syntax in expression.
(gdb) printf "%f %f\n", 3.4, 5.6
Wrong number of arguments for specified format-string
(gdb) quit


	I've figured out the error happens when ALL of the following
are true:

1)	A "printf" command was called
2)	That command line contains a C expression
3)	There is an error in the C expression
4)	The error is detected after parsing a left paren, but before
parsing the corresponding right paren.

	After the above error has happened, subsequence calls to
printf that involve a list of arguments will get the wrong number of
arguments error.


	I also believe that I've found that bug.  In expread.y, there
is a static variable "paren_depth".   Whenever a left paren is
processed by yylex(), paren_depth is incremented by one.  But it is
not reset to zero when an error is detected.  So, next time when
parse_to_comma_and_eval() is called, it will not stop at the correct
position of the comma because paren_depth is NOT zero at that time.

Wilson HO

-------------------------------------------------------------------------------
  W. Wilson Ho		        |  INTERNET: how@iris.ucdavis.edu
  Division of Computer Science	|  UUCP:     {lll-crg, ucbvax}!ucdavis!iris!how
  EECS Department		|
  University of California	|  Phone:    (916)752-7109
  Davis, CA 95616		|
-------------------------------------------------------------------------------