Bounds check & cross-language
N.M. Maclaren
nmm1@cam.ac.uk
Sun Aug 29 17:50:00 GMT 2010
On Aug 29 2010, Dennis Wassel wrote:
>
>> It's only the cross-routine string checking that is the problem.
>> gfortran doesn't check array bounds across routine calls, which means
>> that it will catch only the more obvious bounds errors - only NAG
>> Fortran does the full job. So you don't need to drop ALL string
>> checking.
>
>thanks for the clarification (and sorry for the late feedback)
No problem.
>I think I see what you mean:
>To do this properly I would have to annotate every Fortran routine
>with string argument(s) with a hypothetical
>"no-string-bounds-checking" option, if it is ever called from C. I
>guess one could abuse !GCC$ ATTRIBUTES for this, but I hate the very
>idea. So I guess I am stuck with the all-or-nothing approach of
>disabling bounds checking for every source file with such routines,
>right?
Actually, no, but the alternative approach is very unfashionable (even
is functionally almost equivalent).
All that a Fortran caller that provides bounds has to do is to supply
an identifying flag in a known place. In a good ABI, that could be
done canonically and be reliable (it's needed for reliable debugging,
too). Without that, a suitable hash gives an infinitesimal chance of
an unchecked caller being mistaken for a checked one - remember that the
check is against accident, not malice, and the birthday problem does not
apply, so even a 32-bit hash gives a probability of 2.5x10^-10.
God alone who invented that, but I have been using it for over 30 years.
It's probably one of the much-reinvented technologies, and I was reinventor
number 1,000, or something.
Regards,
Nick maclaren.
More information about the Fortran
mailing list