Article View: gnu.g++.bug
Article #774Re: possible bug in g++ 1.36.2 (01199001)
From: Piercarlo Grandi
Date: Mon, 22 Jan 1990 19:16
Date: Mon, 22 Jan 1990 19:16
46 lines
2289 bytes
2289 bytes
In article <9001190913.aa21588@ICS.UCI.EDU> rfg@ICS.UCI.EDU writes:
// This may be a bug, then again, it may not be.
// It seems that both g++ and Cfront 2.0 effectively pre-scan
// each class declaration and process all data member declarations
// before then process any member function declarations.
This is *required* by C++ 2.0; it is very regrettable, because
it is the *only* case in C or C++ where strict one pass
compilation is not possible, and has dire consequences for the
memory used by a compiler.
This rule is another nefarious consequence of the concept of
member functions (which could be abolished, with all its
attendant problems).
My advice, which is to *never* NEVER ****NEVER**** define a
memeber function in the class body, but to only declare it
there and define it after the class body, avoids many troubles,
and gives a break to the compiler.
// This leads to the interesting error shown below.
// Note that Cfront 2.0 does not even allow the initializer for the static
// data member.
Hey! It should. I have this suspicion that your example is more
subtle than it looks at first sight.
struct foo {
void bar () {}
static void (foo::*member_func) (void) = foo::bar; /* ERROR */
};
// g++-01199001.bug.C:15: incomplete type `foo' does not have member `bar'
Notice also that the signature of 'bar' is 'bar()', while that
of '*member_func' is '(*member_func)(void)'. I don't know with
which options you compiled this...
--
Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk
Technical Details
Message-ID:
<1595@aber-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!dcl-cs!aber-cs!pcgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: gnu.g++.bug Subject: Re: possible bug in g++ 1.36.2 (01199001) Summary: Regrettably, it is not a bug. Message-ID: <1595@aber-cs.UUCP> Date: 22 Jan 90 19:16:21 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Distribution: gnu Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 46