http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60543

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |burnus at gcc dot gnu.org
   Target Milestone|---                         |4.8.3

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Confirmed.

The problem is that "function random" is regarded as (implicit) pure. However,
gfortran's subroutine random_number is properly declared as impure.

Reduced example:

  module m
  contains
    REAL(8) FUNCTION random()
      CALL RANDOM_NUMBER(random)
    END FUNCTION random
  end module m

$ zgrep -i pure m.mod 
0 0 FUNCTION IMPLICIT_PURE) () (REAL 8 0 0 0 REAL ()) 0 0 () () 3 () ()

Draft patch:

--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -4407 +4407 @@ gfc_intrinsic_sub_interface (gfc_code *c, int error_flag)
-  if (gfc_pure (NULL) && !isym->pure)
+  if (!isym->pure && gfc_pure (NULL))
@@ -4413,0 +4414,3 @@ gfc_intrinsic_sub_interface (gfc_code *c, int error_flag)
+  if (!isym->pure && gfc_implicit_pure (NULL))
+    gfc_current_ns->proc_name->attr.implicit_pure = 0;
+

Reply via email to