public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27586]  New: Compile-time warn if arguments don't match in terms of precision
@ 2006-05-13 13:39 tobias dot burnus at physik dot fu-berlin dot de
  2006-05-13 23:01 ` [Bug fortran/27586] " tobias dot burnus at physik dot fu-berlin dot de
  2006-05-13 23:05 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-05-13 13:39 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/27586] Compile-time warn if arguments don't match in terms of precision
  2006-05-13 13:39 [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
@ 2006-05-13 23:01 ` tobias dot burnus at physik dot fu-berlin dot de
  2006-05-13 23:05 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-05-13 23:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tobias dot burnus at physik dot fu-berlin dot de  2006-05-13 23:01 -------
The following is also not caught:
-----------------------------
        subroutine foo(y)
           character(len=20) :: y
           y = 'hello world'
        end

        program test
           character(len=10) :: x
           call foo(x)
           write(*,*) 'X=',x
           pause
        end
-----------------------------

NAG's f95 spits out this error:
Error: test17.f90: Argument Y (no. 1) in reference to FOO from TEST is too
short a character string


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27586


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/27586] Compile-time warn if arguments don't match in terms of precision
  2006-05-13 13:39 [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
  2006-05-13 23:01 ` [Bug fortran/27586] " tobias dot burnus at physik dot fu-berlin dot de
@ 2006-05-13 23:05 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-13 23:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-05-13 23:05 -------
This is really a dup of bug 26227.

*** This bug has been marked as a duplicate of 26227 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27586


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-13 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-13 13:39 [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
2006-05-13 23:01 ` [Bug fortran/27586] " tobias dot burnus at physik dot fu-berlin dot de
2006-05-13 23:05 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).