Why does this simple program segfault?

Anders F Björklund afb at algonet.se
Tue Aug 14 23:38:31 PDT 2007


Bill Baxter wrote:

> I guess the best we can hope for is some kind of better error message 
> than just a generic segfault, or perhaps a compiler warning if you 
> forget to initialize a class instance.

Aren't those segfaults the famous "hardware exceptions", that you get
"for free" instead of the compiler having to throw real exceptions ?

Doesn't seem too impossible to discover in the debugger, I'm worried
that having the compiler error on it would trip up some valid code...

gdb says:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00002d81 in D main () at Tester.d:11
11        fun.testIt();

--anders


More information about the Digitalmars-d-learn mailing list