fortran-wringer-tests icon indicating copy to clipboard operation
fortran-wringer-tests copied to clipboard

Redundant operators

Open ivan-pi opened this issue 1 year ago • 3 comments

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.)
----------------------------^

ivan-pi avatar Sep 27 '24 17:09 ivan-pi

I tried eight Fortran compilers; only Intel complains.

klausler avatar Sep 27 '24 18:09 klausler

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]

tclune avatar Oct 10 '24 18:10 tclune

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.

ivan-pi avatar Oct 11 '24 00:10 ivan-pi