[Bug fortran/27586] New: Compile-time warn if arguments don't match in terms of precision
tobias dot burnus at physik dot fu-berlin dot de
gcc-bugzilla@gcc.gnu.org
Sat May 13 13:39:00 GMT 2006
The following test case uses single precision arguments to a double precision
function.
Expected: Warn during compiling
Actual: No warning is given. ./a.out shows:
0.000000 3.0132665E+23 ! initialized with 2 & sqrt(2)
In order to make it work across files, the .mod file should contain such
information (and it should be used).
>From http://www.polyhedron.com/pb05/linux/diagnose.html
For the following file gfortran should issue a warning as x,y are once real and
once double precision.
---<ARG1.F>--------------------
! argument mismatch - same file
program arg1
call sub(x,y)
print * , x,y
end
subroutine sub(x,y)
double precision x,y
x = 2.0
y = sqrt(x)
end
----------------------------
gfortran-4.2 -Wall -pedantic -fbounds-check ARG1.F
produces no warning
Whereas
ifort64-9.1 -C -check all -warn all,nodec,interfaces -gen_interfaces -traceback
-fpe0 -fpstkchk ARG1.F
fortcom: Error: ARG1.F, line 3: The type of the actual argument differs from
the type of the dummy argument. [X]
call sub(x,y)
---------------^
fortcom: Error: ARG1.F, line 3: The type of the actual argument differs from
the type of the dummy argument. [Y]
call sub(x,y)
-----------------^
g95 -Wall -pedantic -fbounds-check -ftrace=full ARG1.F
In file ARG1.F:3
call sub(x,y)
1
In file ARG1.F:6
subroutine sub(x,y)
2
Warning (155): Inconsistent types (REAL(4)/REAL(8)) in actual argument lists at
(1) and (2)
NAG: f95 -C=all -C=undefined -info -g -gline ARG1.F
Error: /tmp/ARG1.020753.f: Argument X (no. 1) in reference to SUB from ARG1 has
the wrong data type
Error: /tmp/ARG1.020753.f: Argument Y (no. 2) in reference to SUB from ARG1 has
the wrong data type
A meaner test is the following:
---<ARG2A.F>-------------------
! argument mismatch - different file
program arg2
call sub(x,y)
print * , x,y
end
-------------------------------
---<ARG2B.F>-------------------
! argument mismatch - different file
subroutine sub(x,y)
double precision x,y
x = 2.0
y = sqrt(x)
end
-------------------------------
gfortran does not catch the problem either, of g95, ifort and NAGf95 only the
Intel compiler catches this - when compiling ARG2B.F ARG2A.F. (ARG2A.F ARG2B.F
no compiler catches.)
Actually, none of the compilers catches this at run time either.
ifort64-9.1 -C -check all -warn all,nodec,interfaces -gen_interfaces -traceback
-fpe0 -fpstkchk ARG2B.F ARG2A.F
fortcom: Error: ARG2A.F, line 3: The type of the actual argument differs from
the type of the dummy argument. [X]
call sub(x,y)
---------------^
fortcom: Error: ARG2A.F, line 3: The type of the actual argument differs from
the type of the dummy argument. [Y]
call sub(x,y)
-----------------^
compilation aborted for ARG2A.F (code 1)
--
Summary: Compile-time warn if arguments don't match in terms of
precision
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tobias dot burnus at physik dot fu-berlin dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27586
More information about the Gcc-bugs
mailing list