Re: What are the preconditions of newArray#
An Array# of size zero is a perfectly reasonable thing. If it doesn't work, it should (and I vaguely recall making it work at some point in the past, but perhaps I failed to add a test and as a result it has rotted...) Cheers, Simon On 22/08/11 17:08, Johan Tibell wrote: I agree (unless it has a performance cost). I had to fix a couple of bugs in my code associated with generating zero-length arrays. On Mon, Aug 22, 2011 at 5:54 PM, Edward Kmettekm...@gmail.com wrote: It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibelljohan.tib...@gmail.com wrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yangezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
It could well be that it's some later primop that's failing due to the empty size, like my new copyArray# primop. If that's the case I could fix it but I would probably would have to add a branch to the copyArray# primop, which I'm reluctant to do. On Tue, Aug 23, 2011 at 9:47 PM, Simon Marlow marlo...@gmail.com wrote: An Array# of size zero is a perfectly reasonable thing. If it doesn't work, it should (and I vaguely recall making it work at some point in the past, but perhaps I failed to add a test and as a result it has rotted...) Cheers, Simon On 22/08/11 17:08, Johan Tibell wrote: I agree (unless it has a performance cost). I had to fix a couple of bugs in my code associated with generating zero-length arrays. On Mon, Aug 22, 2011 at 5:54 PM, Edward Kmettekm...@gmail.com wrote: It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibelljohan.tib...@gmail.com wrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yangezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
You could make it a precondition of copyArray#, although that's slightly less pleasant from a user's perspective. Cheers, Simon On 23/08/11 21:04, Johan Tibell wrote: It could well be that it's some later primop that's failing due to the empty size, like my new copyArray# primop. If that's the case I could fix it but I would probably would have to add a branch to the copyArray# primop, which I'm reluctant to do. On Tue, Aug 23, 2011 at 9:47 PM, Simon Marlowmarlo...@gmail.com wrote: An Array# of size zero is a perfectly reasonable thing. If it doesn't work, it should (and I vaguely recall making it work at some point in the past, but perhaps I failed to add a test and as a result it has rotted...) Cheers, Simon On 22/08/11 17:08, Johan Tibell wrote: I agree (unless it has a performance cost). I had to fix a couple of bugs in my code associated with generating zero-length arrays. On Mon, Aug 22, 2011 at 5:54 PM, Edward Kmettekm...@gmail.comwrote: It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibelljohan.tib...@gmail.com wrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yangezy...@mit.eduwrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
Right. That's an option. On Tue, Aug 23, 2011 at 10:31 PM, Simon Marlow marlo...@gmail.com wrote: You could make it a precondition of copyArray#, although that's slightly less pleasant from a user's perspective. Cheers, Simon On 23/08/11 21:04, Johan Tibell wrote: It could well be that it's some later primop that's failing due to the empty size, like my new copyArray# primop. If that's the case I could fix it but I would probably would have to add a branch to the copyArray# primop, which I'm reluctant to do. On Tue, Aug 23, 2011 at 9:47 PM, Simon Marlowmarlo...@gmail.com wrote: An Array# of size zero is a perfectly reasonable thing. If it doesn't work, it should (and I vaguely recall making it work at some point in the past, but perhaps I failed to add a test and as a result it has rotted...) Cheers, Simon On 22/08/11 17:08, Johan Tibell wrote: I agree (unless it has a performance cost). I had to fix a couple of bugs in my code associated with generating zero-length arrays. On Mon, Aug 22, 2011 at 5:54 PM, Edward Kmettekm...@gmail.com wrote: It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibelljohan.tib...@gmail.com wrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yangezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yang ezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibell johan.tib...@gmail.comwrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yang ezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
I agree (unless it has a performance cost). I had to fix a couple of bugs in my code associated with generating zero-length arrays. On Mon, Aug 22, 2011 at 5:54 PM, Edward Kmett ekm...@gmail.com wrote: It would still be nice to have a consistent base case. On Mon, Aug 22, 2011 at 3:43 AM, Johan Tibell johan.tib...@gmail.com wrote: On Mon, Aug 22, 2011 at 5:55 AM, Edward Z. Yang ezy...@mit.edu wrote: stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... I would imagine that a zero sized array would be a StgArrPtrs header with its size field set to 0. It's not a very useful thing to have, I admit. If someone (Simon?) can confirm that we don't intend to support zero-length array I'll push a patch that adds a comment. Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: What are the preconditions of newArray#
stg_newArrayzh in rts/PrimOps.cmm doesn't appear to give any indication, so this might be a good patch to add. But I'm curious: what would allocating Array#s of size 0 do? Null pointers? That sounds dangerous... Edward Excerpts from Johan Tibell's message of Fri Aug 19 11:04:48 -0400 2011: Hi, I'm seeing a segfault which I suspect is due to allocating Array#s of size 0, using newArray#. Are zero length arrays allowed? What are the preconditions of newArray#? It'd be great if they were documented. -- Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
What are the preconditions of newArray#
Hi, I'm seeing a segfault which I suspect is due to allocating Array#s of size 0, using newArray#. Are zero length arrays allowed? What are the preconditions of newArray#? It'd be great if they were documented. -- Johan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users