This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug Report: Compilers choke on class::* func pointers [2nd Half]
- To: egcs-bugs at cygnus dot com
- Subject: Bug Report: Compilers choke on class::* func pointers [2nd Half]
- From: Eric McDonald <emcdonal at cps dot cmich dot edu>
- Date: Wed, 06 May 1998 20:10:06 -0400
>Date: Tue, 05 May 1998 01:08:54 -0400
>To: egcs-bugs@cygnus.com, bug-g++@prep.ai.mit.edu
>From: Eric McDonald <emcdonal@cps.cmich.edu>
>Subject: [BUG REPORT]: Potential bug with class:: pointers to member
functions.
>
>Compilers Killed: egcs-1.0.2, gcc-2.8.1
>CC: bug-g++, egcs-bugs
[NOTE: This is the second half of a post from May 5th that was truncated
because of a '.' on a line by itself, and a mail program too stupid to do
anything about it. The first half can be found at:
http://www.cygnus.com/ml/egcs-bugs/1998-May/0066.html
Sorry for any confusion this may have caused.]
>The Relevant Code Snippets:
>
>@@ genexcept.h @@
>[defines and other junk snipped]
>
>class GeneralException{
>
>public:
> GeneralException () : nErrorCode(ERROR_CODE_UNKNOWN), \
> nErrorLevel(ERROR_LEVEL_NONE), \
> sErrorMsg(ERROR_MSG_NONE), \
> sErrorSource(ERROR_SOURCE_UNKNOWN), \
> funcHandler(NULL), \
> nErrorClass(ERROR_CLASS_GENERAL) {}
> GeneralException (int theErrorCode, \
> int theErrorLevel = ERROR_LEVEL_NONE, \
> string theErrorMsg = ERROR_MSG_NONE, \
> string theErrorSource = ERROR_SOURCE_UNKNOWN, \
> void (*theFuncHandler) () = NULL) : \
> nErrorCode(theErrorCode), nErrorLevel(theErrorLevel), \
> sErrorMsg(theErrorMsg), sErrorSource(theErrorSource), \
> funcHandler(theFuncHandler),
nErrorClass(ERROR_CLASS_GENERAL) {}
> GeneralException (const GeneralException& gexSource) : \
> nErrorCode(gexSource.nErrorCode), \
> nErrorLevel(gexSource.nErrorLevel), \
> sErrorMsg(gexSource.sErrorMsg), \
> sErrorSource(gexSource.sErrorSource), \
> funcHandler(gexSource.funcHandler), \
> nErrorClass(ERROR_CLASS_GENERAL) {}
> ~GeneralException ();
>
> void DisplayMessage ();
> void DisplaySource ();
> void ExecuteHandler ();
>
>protected:
> int nErrorCode;
> int nErrorLevel;
> string sErrorMsg;
> string sErrorSource;
> void (*funcHandler) ();
>
> int nErrorClass; // For distinguishing subclasses when using a
> // down-cast pointer.
>
> void SetErrorClass (int);
>
>};
>
>@@ genexcept.cc @@
>[everything trimmed but the working (or should I say, compiling)
ExecuteHandler()]
>
>void GeneralException:: ExecuteHandler (){
>
> if (NULL != funcHandler)
> funcHandler();
>
> if (ERROR_LEVEL_ERROR < nErrorLevel){
> DisplayMessage();
> DisplaySource();
> exit(nErrorLevel);
> }
>
>}
>
>@@ parser.h @@
>[just the declares of the relevant classes, and the ParserException class]
>
>class Parser{
>
>public:
>
>[skip some stuff]
>
>private:
>
>[skip stuff like grammar symbol structs and what-not]
>
> /* Data Structure: Parser Exception */
> class ParserException : public GeneralException{
>
> public:
> ParserException () : GeneralException (), \
> tOffender(ERROR_TOKEN_DEFAULT), \
> gsymMisfit(ERROR_GSYM_DEFAULT) \
> {SetErrorClass(ERROR_CLASS_PARSER);}
> ParserException (int theErrorCode, \
> int theErrorLevel = ERROR_LEVEL_NONE, \
> string theErrorMsg = ERROR_MSG_NONE, \
> string theErrorSource = ERROR_SOURCE_UNKNOWN, \
> void (Parser::* theFuncHandler) () = NULL, \
> token theToken = ERROR_TOKEN_DEFAULT, \
> Parser:: GrammarSymbol theGSym =
ERROR_GSYM_DEFAULT) \
> : GeneralException(theErrorCode, theErrorLevel, \
> theErrorMsg, theErrorSource), \
> funcHandler(theFuncHandler), \
> tOffender(theToken), gsymMisfit(theGSym) \
> {SetErrorClass(ERROR_CLASS_PARSER);}
> ParserException (const ParserException& parsexSource) : \
> GeneralException(parsexSource), \
> funcHandler(parsexSource.funcHandler), \
> tOffender(parsexSource.tOffender), \
> gsymMisfit(parsexSource.gsymMisfit) \
> {SetErrorClass(ERROR_CLASS_PARSER);}
> ~ParserException ();
>
> void ExecuteHandler (); // NOTE: Overrides parent.
>
> protected:
> void (Parser::* funcHandler) ();
> token tOffender;
> Parser:: GrammarSymbol gsymMisfit;
>
> };
>
>[private vars belonging to the parser class]
>
>};
>
>@@ parserexcept.cc @@
>
>[obviously things have been snipped]
>[offending lines of code below]
>
>void Parser:: ParserException:: ExecuteHandler (){
>
> // funcHandler();
> this->funcHandler();
>
>}
>
>
>Please let me know if I am just being stupid and using invalid C++, or if
there is some way I can provide > additional info to help improve the
compilers in question.
>
>BTW, both gcc-2.8.1 and egcs-1.0.2 are a _major_ improvement over the
gcc-2.7.2.1 compiler that I was using. >Thanx for the good work.
>
>
/***************************** Eric McDonald ************************
POP3: emcdonal@cps.cmich.edu; Eric.A.McDonald@cmich.edu; \
Eric.McDonald@usa.net
Finger: emcdonal@mail.cps.cmich.edu
POTS: Home: V[/F/D]: 517-772-9209; Work: V: 517-773-1201
HTTP: [HTML docs under revision]
From the truss man page under SunOS 5.5.1:
"-x [!]syscall,...
Display the arguments to the specified system
calls (if traced) in raw form, usually hexa-
decimal, rather than symbolically. This is
for unredeemed hackers who must see the raw
bits to be happy. Default is -x!all." :-)
********************************************************************/