Bug with ISO_C_BINDING on Mac OS?

Janus Weil janus@gcc.gnu.org
Sat Jun 1 13:29:00 GMT 2013


>> Ok, using TYPE(c_ptr) here, too.
>>
>> However, when the test case is updated accordingly (see attachment), I
>> also end up with a valgrind error on Linux:
>
>
> You didn't do what I proposed: You missed the VALUE for "f":

Sorry, I missed that ...


>     function bzReadOpen (bzerror,f,verbosity,small,unused,nUnused) bind
> (c,NAME='BZ2_bzReadOpen')
>       use, intrinsic :: ISO_C_BINDING
>       integer(c_int) :: bzerror
>       type(c_ptr),VALUE :: f, unused
>       integer(c_int),value :: verbosity,small,nUnused
>       type(c_ptr) :: bzReadOpen
>     end function
>
> Without VALUE, it sometimes showed valgrind problems / segfaulted - and
> sometimes it didn't.

Ok, this version definitely works ...


>>> Ok, in fact it works (on Linux) if I remove the VALUE attribute for
>>> all arguments (updated code attached). Will check if this also fixes
>>> it on Mac OS ...
>>
>> Seems like it does. Thanks for the help and sorry for the noise ...
>
>
> But that shouldn't work. One cannot simply add VALUE attributes at will - it
> has to match what the code expects:

Yes, I'm aware of that. But somehow I always get confused by the
different calling conventions etc - and the fact that things sometimes
just work 'by chance'.

Thanks again,
Janus



More information about the Fortran mailing list