Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Luc Maranget <luc.maranget@i...>
Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ?
Hello
> 
> The issue with threads is a bit more troublesome.  Consider:
> 
>   let x : (int->int) option ref =3D ref (Some (fun x -> x));;
> 
>   let foo z =3D
>       match z with
>         {contents=3DNone} -> 0
>       | {contents=3DSome(f)} -> f(0);
> 
> Now suppose I fork two threads:
> 
> Thread 1:  foo x
> Thread 2:  x :=3D None
> 
> And suppose that Thread 1 runs long enough that it does the first
> match, so it assumes the contents of x is not of the form None. =20
> Now Thread 1 gets descheduled, Thread 2 runs, and sets the
> contents of x to None.  Then Thread 2 continues with the second
> match...
> 
> The question is, does Caml core dump because the pattern matcher
> assumes that the contents *has* to be a Some(-) in the second
> case?  Or does it do the derefence and check atomically?  Or
> does it add a default case that raises a Match exception? =20
The compiled code is something like

 (if match/54 (apply (field 0 match/54) 0) 0)

So the answer is: yes it coredumps.


> 
> -Greg
> -------------------

--Luc
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr