This is exactly how I would characterize you and most others
here.
Well, I'll let the other readers judge who is trying to discuss
things reasonably, and who is simply ignoring the points the
other person has made.
You tell me things, I already know and even agree with and you
insinuate that I suggested things I never did:
* That accessing a freed pointer will usually not result in a
signal or structured exception
* that it would be useless to catch SIGTERM or SIGKILL
* that there are CPUs which do not support catching invalid memory
access
* that dereferencing a null pointer is a programming error
* That calling destructors is dangerous in certain situations (memory
corruption).
(Your default signal/structured-exception handler is free to call
_exit(1) in this case).
But you don't draw any conclusions from all of that. You
continue to argue as if the points the others are bringing up
didn't exist.
Also you are ignoring the advantages of structured exception
handling I mentioned.
No. I specifically addressed them. They only apply to certain
limited situations. What you're suggesting is that we modify
the standard to support a few limited situations, in a way that
would make the language unusable, or difficultly usable, in the
majority of cases. And that would make the language impossible
to implement on most embedded systems, or under Unix.
You were also unable to provide any workable solution (which
does not involve a slowdown or other drawbacks) to the
problems I mentioned:
That's because they're not really problems, at least in most
cases.
1) My main problem: Dealing with writing to memory created via
memory mapped io and sparse files and the case that the system
runs out of disk space which results in a SIGSEGV or SIGBUS on
UNIXs. This means, that one has to allocate disk space before
(which is slow).
Agreed. Now, just how many programs do that? (I've yet to
encounter one.)
2) Just an idea: Catching floating point exceptions instead of
securing the code against invalid arguments (which is not
always possible) or letting the code continue calculating with
NAN or INF (which is very very slow)
You can't require this, because not all systems trap floating
point exceptions. Depending on the system, you likely have an
implementation defined means of doing this aready, if the system
supports it. One of the costs of supporting a lot of different
systems (a goal of C++) is that you do have to use
implementation defined additions for features which aren't
widely implemented.
Given the extension IEEE floating point has taken on, both C and
C++ are moving to providing explicit support for it
(conditionnally, of course---there is a macro you can test to
know whether the target platform is IEEE). I think it would be
a good idea in C++ that part of this support include the
possibility of mapping floating point traps to C++ exceptions,
although I don't know if there has been a proposal in this
direction.
3) Some usefull side effect of structured exception handling:
Catching null pointer access (which I agree is a programming
error and should never occure in release code -- I agree this
is a minor problem)
And you keep on repeating things for which I really do not
understand what your point is:
"Signals are different that Exceptions."
Because you keep coming back and assimulating the two, although
they are two radically different notions.
Historically, they come from opposite ends: an exception is a
way of reporting errors, easier to use than a return code when
the site handling the error is far from the site detecting it,
but still related to the same idea. Under Unix---the world in
which C/C++ developed---a signal was originally a means of
killing a process; the very first signals couldn't be caught,
and the command that generates a signal is still called "kill".
Even today, there's really not much you can do in a signal
handler except set a flag, or abort (not exit); you cannot
unwind the stack, for example.
To recapitulate:
I suggested that a C++ standard should include something like
Microsofts structured exception handling on systems, which are
currently providing signal handling.
See. You're simply ignoring the fact that this is impossible on
most systems which provide signal handling, although this fact
has been pointed out to you several times. You're also ignoring
the fact that the facility only works in limited cases with
Microsoft; it won't work, for example, if the access violation
is triggered in malloc, because of earlier heap corruption.
Anyway, if you're so convinced, you can always write up a
proposal. It will be considered. But I can pretty much guess
what will happen to it---the issue was discussed in committee,
with the representative of Microsoft present, and the end result
was that the representative of Microsoft ended up deciding that
it probably wasn't such a good idea. (And of course, you don't
get it by default with VC++. But then, you don't get any
exception handling by default---you need to specify /EHs or
/EHa, depending on whether you want structured exceptions or
not. But if you try to compile code which uses exceptions,
without specifying one of these, the compiler will suggest
/EHs---even Microsoft knows that structured exceptions are only
for special cases.)