470,874 Members | 1,752 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

dynamic_cast segmentation fault

I have a segmentation fault in the following line using dynamic_cast,
but I can't figure out what's wrong with this.

i appreciate if someone can help. I make sure pm is NOT a null pointer
as I step thru the debugger?

Is there some compiler options I need to enable/not disable in order
for dynamic_cast to work?

bool Grouper::handle(Handler* pm, InputList& bdl, ResultList& grl) {
// Segmentation fault in the following line:
AHandler* hfpm = dynamic_cast <AHandler*> ( pm);

}

class Handler {
// a base class
};

class AHandler : public Handler {

};

Mar 1 '06 #1
3 6207
Pl********@gmail.com wrote:
I have a segmentation fault in the following line using dynamic_cast,
but I can't figure out what's wrong with this.

i appreciate if someone can help. I make sure pm is NOT a null pointer
as I step thru the debugger?
Are you asking? I have no idea how to answer this question. Pointers
can be invalid without being null.
Is there some compiler options I need to enable/not disable in order
for dynamic_cast to work?
How should we know? You need to read the documentation for your compiler
or ask in the newsgroup dedicated to your compiler. Is this your first
time here? Have you read the FAQ yet?
bool Grouper::handle(Handler* pm, InputList& bdl, ResultList& grl) {
// Segmentation fault in the following line:
AHandler* hfpm = dynamic_cast <AHandler*> ( pm);
What *is* the value of 'pm' here? Does it actually point to a valid
'AHandler' or 'Handler'?

}

class Handler {
// a base class
};

class AHandler : public Handler {

};


V
--
Please remove capital As from my address when replying by mail
Mar 1 '06 #2
if you are in the windows enviroment, go to project
settings----c/c++----language, enable the run-time type info to
yes(/GR)

Thanks
Ben

Mar 1 '06 #3
On Wed, 01 Mar 2006 14:57:54 -0800, Plissken.s wrote:
I have a segmentation fault in the following line using dynamic_cast,
but I can't figure out what's wrong with this.

bool Grouper::handle(Handler* pm, InputList& bdl, ResultList& grl) {
// Segmentation fault in the following line:
AHandler* hfpm = dynamic_cast <AHandler*> ( pm);

}

class Handler {
// a base class
};

class AHandler : public Handler {

};


Make sure your base class has virtual functions. RTTI is tied to
polymorpic classes.

- Jay
Mar 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by sivignon | last post: by
3 posts views Thread by diyanat | last post: by
16 posts views Thread by laberth | last post: by
5 posts views Thread by Fra-it | last post: by
27 posts views Thread by Paminu | last post: by
7 posts views Thread by pycraze | last post: by
3 posts views Thread by madunix | last post: by
6 posts views Thread by DanielJohnson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.