fortran-wringer-tests
fortran-wringer-tests copied to clipboard
Redundant operators
module a
public :: operator(==), operator(.foo.)
integer :: b = 33
end module
use a
print *,b
end
Flang and gfortran both ignore the operators. ifort and ifx produce an error:
/app/example.f90(2): error #6714: There is no visible interface-stmt that defines this generic-spec.
public :: operator(==)
--------------^
/app/example.f90(2): error #6714: There is no visible interface-stmt that defines this generic-spec. [FOO]
public :: operator(==), operator(.foo.)
----------------------------^
I tried eight Fortran compilers; only Intel complains.
NAG does provide warnings:
bash-3.2$ nagfor -C=all ~/Fortran/redundant.F90
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7201
Warning: /Users/tclune/Fortran/redundant.F90, line 4: Generic OPERATOR(.EQ.) has no specific procedure
Warning: /Users/tclune/Fortran/redundant.F90, line 4: Generic OPERATOR(.FOO.) has no specific procedure
[NAG Fortran Compiler normal termination, 2 warnings]
I can't see any benefit in allowing redundant stuff. In my eyes it just causes confusion; there are some redundant operators in fpm modules.