www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - classes: Error and Exception

reply Martin <Martin_member pathlink.com> writes:
The following gives "segmentation fault", but maybe it should throw an excetion
like running out of array limits? I I think that it is almost as common mistake
as running out of array bounds.


What do you think about this?

class Ca{
public:
int b;
}

int main(){
Ca a;
try{
a.b=1;
}
catch(Exception e){
printf("ERROR!\n");

}
return 0;
}
Sep 06 2004
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
your code works for me.  i run it and it says ERROR!

i'm using windows though.  i suppose you're using linux?
Sep 06 2004
parent reply Martin <Martin_member pathlink.com> writes:
Interesting, that means, that in Windows D can catch "Segmentation faults", but
in linux not.

Is it so Walter?

In article <chhv3b$1ess$1 digitaldaemon.com>, Jarrett Billingsley says...
your code works for me.  i run it and it says ERROR!

i'm using windows though.  i suppose you're using linux?
Sep 06 2004
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Martin wrote:
 Interesting, that means, that in Windows D can catch "Segmentation faults", but
 in linux not.
 
 Is it so Walter?
This is a known bug/missing feature on Linux. I'm pretty sure that Walter intends to implement this. Of course, if one of us writes some good example code for him, then it would be much easier for him...
Sep 07 2004
parent "Walter" <newshound digitalmars.com> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:chl3eq$2ru9$1 digitaldaemon.com...
 Martin wrote:
 Interesting, that means, that in Windows D can catch "Segmentation
faults", but
 in linux not.

 Is it so Walter?
This is a known bug/missing feature on Linux. I'm pretty sure that Walter intends to implement this. Of course, if one of us writes some good example code for him, then it would be much easier for him...
My experience on low level coding for linux is pretty limited. If someone wants to donate the code for linux that will convert seg faults into exceptions, like the Windows code does in internal\deh.c, I'd love to incorporate it.
Sep 09 2004