Contrary to what the man pages say, double precision constants like '1.d0' get promoted to 16 bytes when using -fdefault-real-8 (without -fdefault-double-8). The man pages at the section of -fdefault-double-8 say however that -fdefault-real-8 does not promote constants like that. Is this an error in the man pages? From the man pages: -fdefault-double-8 Set the "DOUBLE PRECISION" type to an 8 byte wide type. If -fdefault-real-8 is given, "DOUBLE PRECISION" would instead be promoted to 16 bytes if possible, and -fdefault-double-8 can be used to prevent this. The kind of real constants like "1.d0" will not be changed by -fdefault-real-8 though, so also -fdefault-double-8 does not affect it. Using e.g. the following program: program doubletrouble real*8 x double precision y write(*,*) kind(x), kind(y), kind(1.d0) end Compiling without any options gives '8 8 8' as output. Compiling with -fdefault-real-8 gives '8 16 16', while I expected it to be '8 16 8' based on the documentation. This is with gfortran 4.7.0 on Linux x86_64 (Intel Core i5 M 540)
If I replace kind(1.d0) with kind(1.0_8), I get '8 16 8' with -fdefault-real-8. I am in favor to replace 'does promote the default width of DOUBLE PRECISION to 16 bytes if possible' with something such as 'does promote the default width of DOUBLE PRECISION to 16 bytes if possible, as well as double real constants like 1.d0' and 'The kind of real constants like "1.d0"' with 'The kind of real constants like "1.0_8"'.
I am planning to submit the following patch --- ../_clean/gcc/fortran/invoke.texi 2016-03-13 09:07:16.000000000 +0100 +++ gcc/fortran/invoke.texi 2016-04-06 20:44:26.000000000 +0200 @@ -361,9 +361,10 @@ it does not promote variables with expli @opindex @code{fdefault-double-8} Set the @code{DOUBLE PRECISION} type to an 8 byte wide type. Do nothing if this is already the default. If @option{-fdefault-real-8} is given, -@code{DOUBLE PRECISION} would instead be promoted to 16 bytes if possible, and +@code{DOUBLE PRECISION} would instead be promoted to 16 bytes if possible, +as well as double real constants like @code{1.d0}, and @option{-fdefault-double-8} can be used to prevent this. The kind of real -constants like @code{1.d0} will not be changed by @option{-fdefault-real-8} +constants like @code{1.0_8} will not be changed by @option{-fdefault-real-8} though, so also @option{-fdefault-double-8} does not affect it. @item -finteger-4-integer-8
May I suggest the following wording: -fdefault-real-8 Set the default real type to an 8 byte wide type. This option also affects the kind of non-double real constants like 1.0. This option promotes the default width of DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes if possible. If -fdefault-double-8 is given along with -fdefault-real-8, DOUBLE PRECISION and double real constants are not promoted. Note, -fdefault-real-8, does not promote variables with explicit kind declarations. -fdefault-double-8 Set the DOUBLE PRECISION type to an 8 byte wide type. Do nothing if this is already the default. This option prevents -fdefault-real-8 from promoting DOUBLE PRECISION and double real constants like 1.d0 to 16 bytes.
Patch submitted at https://gcc.gnu.org/ml/fortran/2019-01/msg00251.html.
Author: dominiq Date: Wed Jan 30 15:53:51 2019 New Revision: 268396 URL: https://gcc.gnu.org/viewcvs?rev=268396&root=gcc&view=rev Log: 2019-01-30 Dominique d'Humieres <dominiq@gcc.gnu.org> PR fortran/52884 * invoke.texi: Document the promotion of double precision constants. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/invoke.texi
Closing.