[gnu.g++.bug] passing constructor arguments back in G++ 1.27.0

karl@typo.umb.edu ("Karl Berry.") (09/26/88)

This is on a Sun 3 machine, running Sun OS 3.4.

1) A printf statement in parse.y prints something like `State is nn, input 
token number is nnn.' for every syntax error. This is not very nice.

2) The real problem:
passing arguments to a base class constructor doesn't seem to work if the 
derived constructor is defined in the class definition. (Or maybe the problem 
is something entirely different.) In any case, the definitions:

struct base {
   base* next;

   base(base* p) { next = p; }
};

class derived :base {
   derived(int i) :(0) { v = i; }
private:
   int v;
};

compile without complaint under AT&T C++, and GNU C++ gives the following  
results:

% g++ -g -v -c x.cc
g++ version 1.27.0
 /usr/local/gnu/lib/gcc-cpp+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix x.cc /tmp/cca00699.cpp
GNU CPP version 1.27.0
 /usr/local/gnu/lib/gcc-c++ /tmp/cca00699.cpp -quiet -dumpbase x.cc -noreg -version -G -o /tmp/cca00699.s
GNU C++ version 1.27.0 (68k, MIT syntax) compiled by GNU C version 1.28.

At top level:
x.cc:9: parse error before `private'
State is 51, input token number is 287.
x.cc:9: cannot open file parse.output

In function struct derived *derived::derived (int):
x.cc:8: parse error before `0'
State is 50, input token number is 263.
x.cc:8: cannot open file parse.output
x.cc:8: undeclared variable `i' (first use here)
x.cc:8: prior parameter's size depends on `$this'
x.cc:8: prior parameter's size depends on `$this'
x.cc:8: Segmentation violation
g++: Program c++ got fatal signal 11.


It makes no difference if the base is a class or a struct.
(That is, if `struct base' is replaced by `class base', and `:base'
is changed to `:public base', the results are the same.)


karl@umb.edu         ...!harvard!umb!karl