Bug 29505 - Should give an error when using: real :: r; r(j) = ...
Summary: Should give an error when using: real :: r; r(j) = ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-18 19:09 UTC by tobias.burnus
Modified: 2006-10-18 21:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tobias.burnus 2006-10-18 19:09:24 UTC
The following program compiles in gfortran.
I don't know how easily it could be detected, but defining a scalar and using it as an array should be detectable?

For what it is worth: ifort also does not detect this error.
Changing the "integer :: j = 1" into "integer :: j; j = 1" causes gfortran to emit an error: "Unexpected STATEMENT FUNCTION statement" (and also ifort now writes: "This name has not been declared as an array or a function.")

------------------------
program bug
implicit none
real :: del
integer :: j = 1
del(j)=sin(10.0)
print *, del(3)
end
------------------------
Comment 1 kargls 2006-10-18 20:52:58 UTC
Tobias,

The code is valid fortran in that  "del(j) = sin(10)" is a
statement function.  Putting any executable line before that line 
(such as j = 1) causes an error to be emitted.  If you look at the
-fdump-parse-tree you'll see

        symtree: del  Ambig 0
        symbol del (REAL 4)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
                            STATEMENT-PROC FUNCTION)
        value: -5.44021130e-1
        result: del
        Formal arglist: j

I think the bug should be closed as INVALID.
Comment 2 tobias.burnus 2006-10-18 21:11:28 UTC
Yes, you are right. I somehow missed those.

"12.5.4 Statement function
A statement function is a function defined by a single statement.
  R1238 stmt-function-stmt is function-name ( [ dummy-arg-name-list ] )
                                                                = scalar-expr"