472,986 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 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 6570
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.