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

--- Comment #17 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-21 
20:02:20 UTC ---
(In reply to comment #16)
> One thing it relies on is that the compiler recognizes
> that the bad function are not pure, as they have a
> side effect (e.g. accessing module variable call_level).
> If a side effect is able to disable critical optimizations,
> then I'm optimistic that the code will work on most platforms.
> 
> Now as promised, here's the reduced example:

Thanks for the example!

Untested patch:

--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3257,6 +3255,7 @@ pure_subroutine (gfc_code *c, gfc_symbol *sym)
   else if (gfc_pure (NULL))
     gfc_error ("Subroutine call to '%s' at %L is not PURE", sym->name,
               &c->loc);
+  gfc_current_ns->proc_name->attr.implicit_pure = 0;
 }

Reply via email to