(j3.2006) Questions and ideas about writing bind(c) interfaces
Rafik Zurob
rzurob
Sun Sep 27 15:12:52 EDT 2015
Hi Malcolm
> <<<
> It would be nice if iso_c_binding provided a const_c_ptr type and
> a conversion function to convert from const_c_ptr to c_ptr.
> >>>
>
> I disagree. It would be a waste of time and effort, and being
essentially
> uncheckable would not improve reliability more than it disimproves the
user
> experience due to the annoyance factor arising when passing a "const"
> pointer to a procedure that does not modify the target, but does not
declare
> it to be "const".
I think it makes a difference in aliasing, similar to how intent(in) helps
improve the aliasing of Fortran dummy arguments. If one is passing c_ptr
cp to function foo, there is currently no way of expressing in the Fortran
interface that foo will not change the target of cp via cp. So one has to
kill everything aliased to cp. With the const_c_ptr way, one wouldn't
have to kill anything on the call to foo.
Regards
Rafik
More information about the J3
mailing list