<div>Ah, sneaky.&nbsp; That code is fine because it uses unsafeCoerce# on &quot;memcpy&quot;, changing memcpy from whatever type it is, into</div>
<div>MutableByteArray# s# -&gt; MutableByteArray# s# -&gt;&nbsp;Int# -&gt; s# -&gt; (# s#, () #)</div>
<div>&nbsp;</div>
<div>So&nbsp;as long as the GC understands&nbsp;MutableByteArray# it&#39;s safe; it&#39;s relying on the C calling convention being handled properly.<br>&nbsp;</div>
<div><span class="gmail_quote">On 8/21/07, <b class="gmail_sendername">Bulat Ziganshin</b> &lt;<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello Stefan,<br><br>Tuesday, August 21, 2007, 10:08:59 AM, you wrote:<br><br>&gt; Your code is broken in a most evil and insidious way.
<br><br>and this code, too? :)<br><br>freezeSTUArray :: Ix i =&gt; STUArray s i e -&gt; ST s (UArray i e)<br>freezeSTUArray (STUArray l u marr#) = ST $ \s1# -&gt;<br>&nbsp;&nbsp; case sizeofMutableByteArray# marr#&nbsp;&nbsp;of { n# -&gt;<br>
&nbsp;&nbsp; case newByteArray# n# s1#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of { (# s2#, marr&#39;# #) -&gt;<br>&nbsp;&nbsp; case unsafeCoerce# memcpy marr&#39;# marr# n# s2# of { (# s3#, () #) -&gt;<br>&nbsp;&nbsp; case unsafeFreezeByteArray# marr&#39;# s3# of { (# s4#, arr# #) -&gt;
<br>&nbsp;&nbsp; (# s4#, UArray l u arr# #) }}}}<br><br>&gt; Unreproducable bugs are rarely reported, but they do add to people&#39;s<br>&gt; impression of how unstable a language/library is.<br><br><br><br><br>--<br>Best regards,<br>
Bulat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com">Bulat.Ziganshin@gmail.com</a><br><br></blockquote></div><br>