Bug 30487 - Math implicit function in forall statement causes compiler error
Summary: Math implicit function in forall statement causes compiler error
Status: RESOLVED DUPLICATE of bug 30400
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-01-16 20:33 UTC by Milad Fatenejad
Modified: 2007-02-08 07:40 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-01-16 21:30:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milad Fatenejad 2007-01-16 20:33:25 UTC
Hi:
I noticed that whenever I use a math function (such as sqrt, cos, log) in a forall all statement that further uses of that function caused gfortran to say that the function has no implicit type. I've shown an example program below:

program test

  implicit none

  integer :: i
  real :: a, c(5) = (/1.0,2.0,3.0,4.0,5.0/), d(5)

  a = sqrt(2.0)

  d(:) = 0.0

  forall (i = 1:5, sqrt(c(i)) < 2.0)
     d(i) = i
  end forall

end program test


If I try to compile the above program I get the following error:

 In file test.f90:8

  a = sqrt(2.0)
         1
Error: Symbol 'sqrt' at (1) has no IMPLICIT type

If I comment out the line "a = sqrt(2.0)", everything works fine. Also, if I don't use the sqrt test in the forall statement, everything works fine. If you substitute other mathematical functions for sqrt (such as log or cos) it fails to compile in a similar way.

I tried this in the latest experimental build (downloaded from the gfortran wiki) and had similar problems.

Thank You
Comment 1 Tobias Burnus 2007-01-16 21:30:26 UTC
Confirmed with gfortran 4.3.0 20070116.
Comment 2 kargls 2007-01-17 01:37:26 UTC
A workaround for this problem is place parentheses around the
mask in the forall.  The parentheses force evaluation of the
expression whereas gfortran is apparently taking a different
path through the compiler without.

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