This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Fix PR 30814, bounds checking for pack


Thomas Koenig wrote:
I'm still wondering if this is the right approach, though.  I
considered two other options:

a) Pass an additional "bounds_check" argument to the library call.
   Plus:  Can be done on a per-file basis.
   Minus:  Runtime overhead, more compilcated

b) Add another function, with bounds checking.
   Plus: No runtime overhead.
   Minus:  Duplication of code.
>
> I finally setteled on the library flag set by the main program.  Does
> everybody agree?

Here's a third option:

c) Hide boundschecking code in the library between #ifdef BOUNDS_CHECKS. Compile the relevant parts of the library twice, once with -DBOUNDS_CHECK, once without. Either create two separate library files, one with bounds-checking, one without, and link appropriately, or modify the prefix(...) mechanism to give the bounds-checking enabled functions a different name.
Plus: No runtime overhead, no code duplication at the source level.
Minus: Could turn out to be quite complicated to implement.


I assume the runtime overhead of option a) is quite small in practice, as there will be a worst-case maximum of 2 separate checks per dimension (upper and lower-bound) but a lot more elements, so I agree with your choice of option a).

Cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]