This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/37398] New: Statement functions mask missing PURE procedures.
- From: "dominiq at lps dot ens dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Sep 2008 16:55:10 -0000
- Subject: [Bug fortran/37398] New: Statement functions mask missing PURE procedures.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Following the fix of pr35837 by Daniel Kraft (thanks for it) I found that it
also fixed a reject-valid bug for the comment #1 in pr29389. In the process
this uncovered an accept-invalid bug as shown by the following modification of
gfortran.dg/stfunc_6.f90:
! { dg-do compile }
! Tests the fix for the second bit of PR29389, in which the
! statement function would not be recognised as not PURE
! when it referenced a procedure that is not PURE.
!
! This is based on stfunc_4.f90 with the statement function made
! impure by a reference to 'v'.
!
! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
INTEGER :: st1, i = 99, a(4), q = 6
st1 (i) = i * i * i
st3 (i) = i * v(i) ! This Ok
FORALL(i=1:4) a(i) = st1 (i)
FORALL(i=1:4) a(i) = u (a(i)) - a(i)** 2
if (any (a .ne. 0)) call abort ()
if (i .ne. 99) call abort ()
FORALL(i=1:4) a(i) = st3 (i) ! This should give "Error: reference to non-PURE
'v' at (1) is inside a FORALL block"
FORALL(i=1:4) a(i) = v (i) ! This gives "Error: reference to non-PURE 'v' at
(1) is inside a FORALL block"
contains
pure integer function u (x)
integer,intent(in) :: x
st2 (i) = i * v(i) ! { dg-error "non-PURE procedure" }
u = st2(x)
end function
integer function v (x)
integer,intent(in) :: x
v = i
end function
end
Since v() is not PURE, st3() is also not PURE and its use in a FORALL construct
should be rejected as it is for v(). Note that the same constraint applies for
the mask. So far I have been unable to see if a similar constraint applies for
WHERE blocks.
--
Summary: Statement functions mask missing PURE procedures.
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dominiq at lps dot ens dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37398