On 11/06/13 08:20, Ian Lance Taylor wrote:
On Wed, Nov 6, 2013 at 7:15 AM, Richard Biener
<richard.guent...@gmail.com> wrote:
But I think that you cannot transform
foo ()
{
*0 = 1;
}
to __builtin_trap as you can catch the trap via an exception handler
in a caller of foo, no?
That is true. OK, I can see an argument that when using
-fnon-call-exceptions that kind of code should not be changed to call
__builtin_trap.
In that case I think it would be fine to run the isolate paths
optimization, but to not omit the actual dereference of the NULL
pointer (possibly the dereference could be followed by a trap).
That would be trivial to implement. I went back and forth on whether to
to leave the *0 or issue the trap. A program could catch the *0 and do
something in its handler. Changing the *0 to a trap would change hte
program's behaviour if it took different action in the handler on the trap.
The trap works better in other cases that don't involve a dereference
though. For example, if a function has an argument that is marked as
must be non-null and we find a path which passes null for that argument
trapping seems best.
jeff