From: Tobias Burnus on
glen herrmannsfeldt wrote:
> It is common, but not required, for the KIND values for INTEGER
> and REAL to overlap. If they didn't, compilers would immediately
> detect the use of a SELECTED_REAL_KIND value in an INTEGER context.
>
> Presumably this happens rarely enough that there haven't been
> complaints to compiler writers.

Even if there were, too many program(mer)s assume that kind=8 is double
precision, kind=4 is default integer/default real and that
integer(kind=8) exists. That goes back to the rather common REAL*8
syntax; although kind numbers do not need to be the same, many users
assume they are!

The NAG compiler, which uses by default different kind numbers, has
consequently an option -kind=byte to allow these kind numbers.

Of cause, it would be possible to add such an option to other compilers,
but I doubt that that will ever become the default setting.

* * *

Side remark: gfortran by default does not allow assigning numbers which
overflow but prints (at compile time):

Error: Arithmetic overflow converting REAL(8) to REAL(4) at (1). This
check can be disabled with the option -fno-range-check

However, some people fail to read this error message and even ask in
mailing lists what they should do ...

Tobias
From: robin on
"e p chandler" <epc8(a)juno.com> wrote in message news:hndmgu$bnk$1(a)news.eternal-september.org...
|
| "robin" <robin_v(a)bigpond.com> wrote in message
| news:WMqmn.12597$pv.5700(a)news-server.bigpond.net.au...
| > "e p chandler" <epc8(a)juno.com> wrote in message
| > news:hncc0c$bgj$1(a)news.eternal-september.org...
| > |
| > | "Luka Djigas" <ldigas@___gmail___.com> wrote in message
| > | news:9n9jp5pge81lpmv4qfk810rugdbqupvike(a)4ax.com...
| > | >
| > | > I find this part terribly confusing. Not your answer per se, but the
| > part
| > | > about reals and integers.
| > | > If a parameter is declared as real, shouldn't it be considered as such
| > | > even with the
| > | > dot missing ?
| > |
| > | But that does not make sense, though I too was confused by the
| > |
| > | d=1_dp / 2_dp
| > |
| > | I have learned that the types of operands on the right are not promoted
| > to
| > | (or related to) the type of the variable on the left. Instead, 1/2 is
| > | truncated to 0 and assigned to d.
| > |
| > | Suppose for the sake of argument that we want this type of error to be
| > | detected. dp is of type integer. Any other integer that evaluates to a
| > valid
| > | kind for an integer could be mis-used in the same way without producing
| > an
| > | error.
| > | Yet "dp" is not bound in any way to type "real". There is no type in
| > Fortran
| > | such as "kind_specifier_of_real". Perhaps there should be, but now it's
| > | probably too late as that would break existing code unless some *new*
| > | inquiry functions were added to the language that returned enumerators
| > of
| > | the proper "type". (Sorry about that!)
| >
| > There's no need whatsoever for anything like that.
| >
| > All that is required is for vendors to use different kind numbers
| > for EVERY kind type.
| >
| > This is perfectly permissible, since the kind numbers are entirely
| > arbitrary.
| >
| > Thus, the problem could be solved virtually immediately.
|
| OK. But I don't think the language standards will ever be written at that
| level of detail. [smile].

It's an implemntation issue. It doesn't need a directive from
the standard, but it certainly would help.


From: robin on
"Tobias Burnus" <burnus(a)net-b.de> wrote in message news:4B9A9209.3030702(a)net-b.de...
| glen herrmannsfeldt wrote:
| > It is common, but not required, for the KIND values for INTEGER
| > and REAL to overlap. If they didn't, compilers would immediately
| > detect the use of a SELECTED_REAL_KIND value in an INTEGER context.
| >
| > Presumably this happens rarely enough that there haven't been
| > complaints to compiler writers.
|
| Even if there were, too many program(mer)s assume that kind=8 is double
| precision, kind=4 is default integer/default real and that
| integer(kind=8) exists.

Any assumption like that makes the code non-portable.