On Fri, Feb 17, 2012 at 2:12 PM, Simon Marlow <[email protected]> wrote:
> On 17/02/12 19:36, John Meacham wrote:
>>
>> It isn't local to a file though because it changes the ABI, for instance
>>
>> void foo(off_t *x);
>>
>> it will blow up if called from a file with a differently sized off_t.
>
>
> But we're talking about Haskell code here, not C code. There's no way for
> something to "blow up", the typechecker will catch any discrepancies.
>
> Perhaps I don't understand what problem you're thinking of - can you give
> more detail?
Someone writes a C function that returns an off_t * that is foreign
imported by a haskell
program using Ptr COff, the haskell program then writes to the output
pointer with the COff
Storable instance. However the imported function was compiled without
64 bit off_t's so it
only allocated 32 bits to be written into so some other memory gets
overwritten with garbage.
64 bit off_t's change the ABI of called C functions
much like passing -m32 or -mrtd does so should be considered a
all-or-nothing sort of thing. In
particular, when ghc compiles C code, it should make sure it does it
with the same ABI flags
as the rest of the thing being compiled.
John
environment as the rest of the code.
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users