Re: segmentation fault exception handling
"Vasileios Zografos" <firstname.lastname@example.org> wrote in message
> Hi, I have the following piece of code which sometimes throws a
> segmentation fault, because this.x, this.y, this.z might be unallocated
> (and it is not possible to initialize them). Its more of a geometric
> problem than programming fault.
Seg-faults during access to data members usually indicates that
the whole object itself has not been allocated adequately.
Does the 'this' pointer happen to be NULL when the segfault occurs?
Maybe what you want to do is a check such as:
if( this==0 ) .... // handle error condition...
It works in practice on some platforms, but is a bad idea in
any case, as this formally leads to undefined behavior.
As others mentioned, it *is* a programming fault to call
an object that hasn't been allocated and constructed.
The design of your code needs to be changed to avoid
Feel free to provide more details if you want further guidance.
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Soft Dev Manger, XiTact <> http://www.xitact.com
Brainbench MVP for C++ <> http://www.brainbench.com
|All times are GMT. The time now is 11:02 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.