Article View: gnu.g++.bug
Article #1445passing constructor arguments back in G++ 1.27.0
From: "Karl Berry."
Date: Mon, 26 Sep 1988 00:09
Date: Mon, 26 Sep 1988 00:09
54 lines
2202 bytes
2202 bytes
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
Technical Details
Message-ID:
<8809260009.AA00706@typo.umb.edu>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!typo.umb.edu!karlShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!typo.umb.edu!karl
From: karl@typo.umb.edu ("Karl Berry.")
Newsgroups: gnu.g++.bug
Subject: passing constructor arguments back in G++ 1.27.0
Message-ID: <8809260009.AA00706@typo.umb.edu>
Date: 26 Sep 88 00:09:48 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 53