perfomance penalty in using execption handling..

A

A. Saksena

Hi,
Do anybody have an idea of the performance penalty while using exception
handling (specially with g++)

Abhishek
 
P

Phlip

A. Saksena said:
Do anybody have an idea of the performance penalty while using exception
handling (specially with g++)

Can you write a few functions, call them 10,000 times, time test them, and
run them with and without exception handling turned on in the compiler?

(And why do you need performance?)
 
S

Steven T. Hatton

Jesper said:
http://www.codeproject.org/cpp/exceptionhandler.asp#xx515459xx
lots of compilers do not pay any performance penalty, unless an exception
is thrown... So if you code that way, that exceptions are truly
exceptional, you should
have no penalty...

"For this discussion, I will consider exceptions to be those that are
explicitly thrown or occur due to conditions like divide by zero or null
pointer access."

C++ programmers catching null pointer exceptions? I'll let you know when I
stop laughing. :-D
 
P

Peter Koch Larsen

Steven T. Hatton said:
"For this discussion, I will consider exceptions to be those that are
explicitly thrown or occur due to conditions like divide by zero or null
pointer access."

C++ programmers catching null pointer exceptions? I'll let you know when I
stop laughing. :-D

Visual C++ in its standard configuration allow null-pointer exceptions to be
catched, so there's not really much to laugh at. And if you continue your
laughs, I can tell you that this is completely compliant.

Apart from that, the link seems to be about what Microsoft calls "structured
exception handling" (a bit like Unix signals). I only skimmed that page,
however.

/Peter
 
O

Old Wolf

Peter Koch Larsen said:
"Steven T. Hatton" <[email protected]> skrev i en meddelelse: (whatever that means)

Visual C++ in its standard configuration allow null-pointer
exceptions to be catched,

Null pointer accesses don't generate an exception.
Maybe you mean that Visual C++ generates an exception for null-pointer
accesses?
And if you continue your laughs, I can tell you that this is
completely compliant.

This means it would have to check every single pointer
access (and every division, if it also generates exceptions for
divide-by-zero), so in the context of the OP's question
"what overhead?", the answer would have to be "a lot".
 
P

Peter Koch Larsen

Old Wolf said:
Null pointer accesses don't generate an exception.
Maybe you mean that Visual C++ generates an exception for null-pointer
accesses?


This means it would have to check every single pointer
access (and every division, if it also generates exceptions for
divide-by-zero), so in the context of the OP's question
"what overhead?", the answer would have to be "a lot".

No - you are misunderstanding my post - especially the part you snipped ;-)

I am saying that one legal behaviour of dereferencing a null pointer is to
throw an exception. This is so because the behaviour in this case - and
other cases of this nature - is unspecified: anything can happen.

/Peter
 
O

Old Wolf

Peter Koch Larsen said:
No - you are misunderstanding my post - especially the part you snipped ;-)

I am saying that one legal behaviour of dereferencing a null pointer is to
throw an exception. This is so because the behaviour in this case - and
other cases of this nature - is unspecified: anything can happen.
Yes, we all know that. What has that got to do with whether it is
laughable to capture null pointer exceptions? So I snipped parts
related to that.
I repeat the assertion of Steven T. Hatton:

I agree, you seem to disagree, why? (The fact that null pointer
exceptions exist does not imply that catching them is not laughable).
 
P

Peter Koch Larsen

Old Wolf said:

Why the above statement if You do not believe that C++ should throw in case
of accessing a null pointer? That is how i took and - until i saw your "we
all know that" remark later.
Please note that i have not in any post (in this thread or elsewhere)
indicated that the throw was sensible.
Yes, we all know that. What has that got to do with whether it is
laughable to capture null pointer exceptions? So I snipped parts
related to that.

It is not so laughable to catch these if they are thrown, is it? There are
situations where a catch (...) is justified and in these situations you
will - with a given configuration of some compilers - catch null pointer
exceptions and stuff like that.
I repeat the assertion of Steven T. Hatton:


I agree, you seem to disagree, why? (The fact that null pointer
exceptions exist does not imply that catching them is not laughable).

Well - let us just agree that our sense of humour differs, then ;-)

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top