Bummer, can't debug ieee_selected_real_kind

Steve Kargl sgk@troutmask.apl.washington.edu
Sun Dec 30 19:49:00 GMT 2018


On Sun, Dec 30, 2018 at 11:04:06AM -0800, Steve Kargl wrote:
> On Sun, Dec 30, 2018 at 08:58:09AM -0800, Steve Kargl wrote:
> > On Sun, Dec 30, 2018 at 03:39:04PM +0100, Thomas Koenig wrote:
> > > 
> > > > It seems someone hase broken the ability to use a debugger
> > > > with f951 if the Fortran includes 'use ieee_arithmetic'
> > > 
> > > I can reproduce the problem :-(
> > > 
> > > While it is not perfect, you could use
> > > 
> > > (gdb) r -I /home/ig25/lib/gcc/x86_64-pc-linux-gnu/9.0.0/finclude ieee.f90
> > > 
> > > where /home/ig25 is your $(PREFIX) to get the compiler to run, at
> > > least.  And yes, this is a pain.
> > 
> > Still doesn't work.
> > 
> 
> The logic in module.c (gfc_use_module) is confusingly messed up.
> 
> Given a module name from a USE statement such as 'ieee_arithmetic',
> the function first tries to open the module as a non-intrinsic
> module in lines 6967:6971.  This works for 'ieee_arithmetic', because
> the code that should mark 'ieee_arithmetic' as intrinsic occurs in
> lines 7015-7021.  But, this code is guarded by 'if (module_fp == NULL ...)
> where module_fp cannot be NULL because gfortran as previously opened
> the module file as non-intrinsic.
> 
> What is baffling is how does gfortran work when executed with the
> 'gfortran' driver instead of directly using f951?

Well, fixing the logic in module.c to check for intrinsic modules
first doesn't work with f951, because intrinsic_modules_dirs is NULL.
The trick of using 'run -I/path/to/finclude' fails, because it adds
/path/to/finclude to module_dirs, which isn't used for intrinsic
modules.


ieee_selected_real_kind is quite broken.  If used in an
initialization an expression such as

   ! Select type with a range of at least 200. 
   integer, parameter :: i = ieee_selected_real_kind(r=200)  

keywords are not honored.  simply_ieee_selected_real_kind
assumes arg[0] is p (precision), arg[1] is r (range) and
arg[2] is radix (radix).  This is caused by using 
'arg = expr->value.function.actual', which simply enumerates
the actual arguments.  gfortran likely needs to check against
the formal arguments to determine keywords.  But I cannot
verify this, because running f951 in the debugger cannot load
intrinsic modules.

ieee_selected_real_kind is additionally broken because 
the module constains exactly one INTERFACE for the
function.  For a architecture with INTEGER(1,2,4,8,16)
types, there are 125 possible INTERFACEs.  So, gfortran
is missing 124 INTERFACEs.

-- 
Steve



More information about the Fortran mailing list