https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82143

--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Sep 08, 2017 at 04:09:24PM +0000, dominiq at lps dot ens.fr wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82143
> 
> --- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > -fdefault-real-8 promotes some things that are REAL(4)
> > to REAL(8), and if available it promotes some things from REAL(8) to
> > REAL(16).
> 
> Not exactly: -fdefault-real-8 promotes some things that are REAL
> to REAL(8) and DOUBLE PRECISION to REAL(16). Variables with a
> KIND (say REAL(4) or REAL(8) are left unchanged.

Which is what I said as in "some things" are promoted.  REAL and
REAL(4) are the exact same type unless one use a broken-by-design
compiler option that maps REAL to DOUBLE PRECISION while leaving REAL(4)
unchanged or one has a myoptic view of Fortran's type system.

> This is the difference with -freal-4-real-8 which converts all
> the REAL* to REAL(8). The interest of -fdefault-real-8 compared to
> -freal-4-real-8 is when you use libraries expecting REAL(4)
> arguments (my use a long time ago was with etime).

This, in fact, is a great example of why -fdefault-real-8 should
never be used.  The proper method of porting a code/library is to
inspect and write the necessary intrinsic procedures.  For this
case, etime is a (nonstandard) specific intrinsic subprogram for
REAL and by extension REAL(4) (unless one uses a broken-by-design
option that maps REAL to DOUBLE PRECISION while leaving REAL(4)
unchanged) and dtime is for DOUBLE PRECISION.  etime is not a generic
subprogram.  Blindly using -fdefault-real-8 and expecting things
to just work is a sure fire way of shooting oneself in the foot.

One also needs to keep in mind that (old crusty) codes/libraries can
contain code that intermixes REAL, REAL*4, and REAL(4).  These
types of libraries sometimes/typically use COMMON and EQUIVALENCE.
-fdefault-real-8 may not (or more likely does not) preserve storage
associate while -freal-4-real-8 does.

Reply via email to