[Bug fortran/95647] New: operator(.eq.) and operator(==) treated differently
longb at cray dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 11 21:14:11 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95647
Bug ID: 95647
Summary: operator(.eq.) and operator(==) treated differently
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: longb at cray dot com
Target Milestone: ---
> cat test.f90
program test
use, intrinsic :: ieee_arithmetic, only : &
& ieee_class, &
& ieee_class_type, &
& ieee_negative_normal, &
& ieee_positive_normal, &
& operator(.eq.)
! use, intrinsic :: ieee_arithmetic
real(4) r4
type(ieee_class_type) class1
r4 = 1.0
class1 = ieee_class(r4)
if (class1 .eq. ieee_positive_normal) print *, 'yes'
r4 = -1.0
class1 = ieee_class(r4)
if (class1 .eq. ieee_negative_normal) print *, 'yes'
end program test
Try test.f90 with 3 compilers:
> ftn test.f90
./a.out
yes
yes
> module swap PrgEnv-cray PrgEnv-intel
> ifort test.f90
> ./a.out
yes
yes
> module swap PrgEnv-intel PrgEnv-gnu
> gfortran test.f90
test.f90:6:43:
6 | & ieee_positive_normal, &
1
Error: Intrinsic operator '.eq.' referenced at (1) not found in module
'ieee_arithmetic'
test.f90:13:18:
13 | if (class1 .eq. ieee_positive_normal) print *, 'yes'
1
Error: Operands of comparison operator '.eq.' at (1) are
TYPE(ieee_class_type)/TYPE(ieee_class_type)
test.f90:16:18:
16 | if (class1 .eq. ieee_negative_normal) print *, 'yes'
1
Error: Operands of comparison operator '.eq.' at (1) are
TYPE(ieee_class_type)/TYPE(ieee_class_type)
Alternate test case:
> diff test.f90 test1.f90
7c7
< & operator(.eq.)
---
> & operator(==)
Works better:
> ftn test1.f90
> ./a.out
yes
yes
> module swap PrgEnv-cray PrgEnv-intel
> ifort test1.f90
> ./a.out
yes
yes
> module swap PrgEnv-intel PrgEnv-gnu
> gfortran test1.f90
> ./a.out
yes
yes
Referencing .eq. or == should have the same effect.
Curiously, the case that works is the one where the USE ONLY clause specifies
operator(==) and the statements that reference that operator are written using
.eq.
More information about the Gcc-bugs
mailing list