Bug 27587

Summary: Warn when Scalar constant passed to array dummy argument
Product: gcc Reporter: tobias.burnus
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: enhancement CC: gcc-bugs, pault, tobias.burnus
Priority: P3    
Version: 4.2.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description tobias.burnus 2006-05-13 13:56:03 UTC
Taken from http://www.polyhedron.com/pb05/linux/diagnose.html
----<ARG7.FOR>-------
      real function same(x)
      implicit none
      real x(1)
      same = x(1)
      end
      program xtwice
      implicit none
      real same
      external same
      print*,same(10.0)
      print*,'Bug not caught!'
      end
----------------------

Current behaviour: prints 10.00000
Expected: Warn/error that argument is not an array.

~> gfortran-4.2 -Wall -pedantic -fbounds-check ARG7.F
ARG7.F:34: warning: no newline at end of file
~> ./a.out
   10.00000
 Bug not caught!


Comparison with other compilers:

ifort64-9.1 -C -check all -warn all,nodec,interfaces -gen_interfaces -traceback -fpe0 -fpstkchk ARG7.F
fortcom: Error: ARG7.F, line 31: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argu
ment is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element.   [X]
      print*,same(10.0)
-------------^
compilation aborted for ARG7.F (code 1)


NAG: f95 -C=all -C=undefined -info -g -gline ARG7.F
Error: /tmp/ARG7.022067.f: Argument X (no. 1) in reference to SAME from XTWICE is not an array
[f95 error termination]
Comment 1 Andrew Pinski 2006-05-13 23:18:48 UTC
This is another dup of bug 26227.

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