Mail Archives: djgpp/1998/12/29/13:20:29
From: | OLIVERWU AT ms4 DOT url DOT com DOT tw (OliverWu)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | General Protection Fault when using dynamic_cast<>()
|
Date: | Mon, 28 Dec 1998 01:19:28 GMT
|
Organization: | National Taiwan University
|
Lines: | 80
|
Message-ID: | <3686d822.17161721@news.ntu.edu.tw>
|
NNTP-Posting-Host: | tawar.m3.ntu.edu.tw
|
X-Newsreader: | Forte Free Agent 1.11/32.235
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi,
I'm having trouble running this program. A runtime error,
General Protection Fault, occurs when I'm trying to run the ctor
postfix_statement::postfix_statement(const infix_statement &)
/*--------------------------Program begins--------------------------*/
class element;
class statement_operator: public element;
class statement_operand: public element
class statement;
class infix_statement;
class postfix_statement
{ /* ... */
public:
postfix_statement::postfix_statement(const
infix_statement &);
/* ... */
};
postfix_statement::postfix_statement(const infix_statement &data)
{ content_list_i i;
list<element> temp; // temp content
stack<element> temp_operator; // temp operator
statement_operator test;
for (i=data.content.begin(); i!=data.content.end(); i++)
switch (i->e_type())
{ case 0: // operand
temp.push_back(*i);
break;
case 1: // operator
if (i->e_name()==string(")"))
/*problem
{
for(;temp_operator.top().e_name()!=string("("); )
{
temp.push_back(temp_operator.top() );
temp_operator.pop();
}
temp_operator.pop(); // pop")"
} // consider ")" especially
*/;
else
/*problem
{ test=*( dynamic_cast<const
statement_operator*>( &(*i) ) );
for(;!prior_to(test,*(dynamic_cast<statement_operator*>(&(temp_operator.top()))));)
{
temp.push_back(temp_operator.top());
temp_operator.pop();
}
temp_operator.push( *(dynamic_cast<conststatement_operator*>(&(*i))));
}
*/;
break;
}
}
/*---------------------------Program ends---------------------------*/
I believe the problem is in those two segments marked by /**/,
but I can't figure it out. Is it possible that I've missed something
in calling dynamic_cast<>()?
BTW, I compiled this with djgpp 2.8.1, and "gcc -c -Wall",
"gxx -o".
I'd apperciate anyone's help. Thanx.
OliverWu
b6705019 AT im DOT ntu DOT edu DOT tw
OliverWu
OLIVERWU AT ms4 DOT url DOT com DOT tw
- Raw text -