473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 6625
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script...
3
by: diyanat | last post by:
i am writing a cgi script in C using the CGIC library, the script fails to run, i am using apache on linux error report from apache : internal server error Premature end of script headers:...
16
by: laberth | last post by:
I've got a segmentation fault on a calloc and I don'tunderstand why? Here is what I use : typedef struct noeud { int val; struct noeud *fgauche; struct noeud *fdroit; } *arbre; //for those...
3
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
27
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! ...
7
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.