Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!mit-eddie!cybvax0!amit From: amit@cybvax0.UUCP (Amit Green) Newsgroups: comp.lang.c++ Subject: Bug (Cybermation #1) with fix: lost declaration. Message-ID: <1507@cybvax0.UUCP> Date: 3 Jan 88 04:49:40 GMT Reply-To: amit@cybvax0.UUCP (Amit Green) Organization: Cybermation, Inc., Cambridge, MA Lines: 55 Problem: double x (a, b, c, d) long a; double b, c; char d; { return a + b + c + d; // Avoid "not used" error message } Produces the following code (shortened & comment added): "", line 1: warning: old style definition of x() /* <> */ double x (_au0_a , _au0_b , _au0_c , _au0_d ) long _au0_a ; double _au0_b ; int _au0_c ; // <= This line is wrong, should be a double char _au0_d ; { return (((_au0_a + _au0_b )+ _au0_c )+ _au0_d ); } ; Notice: The declaration of 'c' as a double is lost (and it defaults to an int). In fact the following may be presented to the compiler: double x (a, b, c, d) long a; double b, c; char d; short c; // Redeclare 'c' as the declaration above was lost { return a + b + c + d; // Avoid "not used" error message } Analysis: gram.y (from cfront 1.2.1) has a bug: line 1: /*ident "@(#)cfront:src/gram.y 1.10" */ line 1225: error("FD inAL (%n)",$2); line 1226: else if ($1) line 1227: $1->add($2); The statement should be '$1->add_list($2)' since '$2' may be list, as it is in the declaration 'double b, c'. The problem exist only when '$1' is already a list (as it is from the declaration 'long a'), and is then appended to again (as it is in the declaration 'char d'). Final Comment: This bug may have been mentioned before, I am not sure. I have printed out all the previous message since comp.lang.c++ started (even from when it was called net.lang.c++), and am still in the process of reading them; if this is a repeat, sorry. Amit Green {harvard,mit-eddie}!cybvax0!amit