Bug 35769

Summary: inappropriate FORALL error
Product: gcc Reporter: Dick Hendrickson <dick.hendrickson>
Component: fortranAssignee: Paul Thomas <pault>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3 Keywords: rejects-valid
Version: 4.4.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: 4.4.0 Last reconfirmed: 2008-03-30 21:27:35
Bug Depends on:    
Bug Blocks: 32834    

Description Dick Hendrickson 2008-03-30 20:45:00 UTC
The following (silly) program gives an incorrect error message.
There is only one assignment to each diagonal element of
the array.  I don't feel strongly about this because FORALL
is sort of a junk feature and this is an unlikely programming
style.  But, to be correct you should downgrade from ERROR
to WARNING for the message severity.

Dick Hendrickson

      program forall_warn
      integer  lda(10,10)

      FORALL(J1=1:10, J2=1:10,  J1 .EQ. J2) LDA(J1,J1) = 1

      end


gfortran:gfortran forall_warn.f
forall_warn.f:4.47:

      FORALL(J1=1:10, J2=1:10,  J1 .EQ. J2) LDA(J1,J1) = 1
                                              1
Error: The FORALL with index 'j2' cause more than one assignment to this object
at (1)
Comment 1 Tobias Burnus 2008-03-30 21:27:35 UTC
Confirm. I agree that it is valid (although bad style) code.

I think there should be no warning printed if a index-name is used in the scalar-mask-expr. Otherwise, if it is neither used in the scalar-mask-expr nor in the forall-body-construct, I think it makes sense to print a warning; this is actually was ifort does.
Comment 2 Mikael Morin 2008-11-05 19:43:29 UTC
This was fixed by Paul in his patch for PR37445. 
Assigning to him.
Comment 3 Paul Thomas 2008-11-08 06:50:12 UTC
Fixed on trunk and 4.3.

Thanks for the report.

Paul