This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add NON_RECURSIVE attribute for procedures


On Wed, Dec 20, 2017 at 11:37 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Janne,
>
> I think you need a few more test cases, like (compile with -fcheck=all
> and -std=f2018):
>
> module foo
> contains
>   subroutine f(n)
>     call g(n-1)
>   end subroutine f
>   subroutine g(n)
>     if (n<0) return
>     call f(n-1)
>   end subroutine g
> end module foo
> program main
>   use foo
>   call f(10)
> end program main
>
> Also, there should be a run-time check that the above fails
> with -std=f2018, -fcheck=all and the NON_RECURSIVE attribute.

Ok, will do.

> However, I am not sure we should make f2018 the default standard as yet,
> especially since some things have not yet been ironed out, but I am
> open to discussion on that.

Seems this is the wrong patch to complain about, since
https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01129.html was already
committed. :) And also before that, GFC_STD_F2015 (the previous name
of GFC_STD_F2018) was an alias for GFC_STD_GNU. So whatever post-F2008
features we have implemented (including the f2008ts stuff) have
already been allowed. I think, in general, our current system where
-std=gnu means roughly "everything we have implemented so far, except
legacy extensions that break standards conformance" is pretty good.

As far as I understand N2137 from July 2017 is quite close to the
final standard (it's apparently a CD, "candidate draft"); as they are
planning publication in 2018 there's not much time left for changes.
More info https://wg5-fortran.org/f2018.html . N2141 contains comments
on N2137, you can see it's minor edits and clarifications, not any
large disagreements.

Now, to play devils advocate with my own patch, one can make the case
that before making procedures recursive by default we should fix
-frecursive / -fmax-stack-var-size so that it's robust in the face of
recursion (and multi-threaded access) and also prevents blowing up the
stack. See also thread at
https://gcc.gnu.org/ml/fortran/2017-12/msg00082.html . My current
thinking is to remove -frecursive (keep the option for backwards
compatibility, but do nothing), and make -fmax-stack-var-size switch
to the heap instead of static memory. Unfortunately I got a bit stuck
here, since in trans-decl.c where this is done we no longer have
access to the statement block, so there's no place to put the
free()'ing of the variable before exiting the scope. Also, how to
switch the type to a pointer without breaking anything? So some more
invasive surgery is needed.


-- 
Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]