https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91413
--- Comment #7 from Janne Blomqvist <jb at gcc dot gnu.org> --- (In reply to Tobias Burnus from comment #6) > Currently, direct recursive use is still not permitted: > > Error: Function ‘faculty’ at (1) cannot be called recursively, as it is not > RECURSIVE > > This has to be turned into "Error: Fortran 2018: ... without RECURSIVE". The more I think about this, the more I think the correct course of action is to just bite the bullet and make -frecursive the default. Having some threshold where we switch from stack to heap allocation is certainly less bad than switching to static memory like we do now, but it's still going behind the back of the user doing something the user didn't actually request (by using allocatables). > We also have to think about how to handle the -f(no-)automatic -frecursive > etc. with this change. – As "SAVE" is also allowed in recursive functions, > we just need to ensure that the old semantic stays the same and write a few > more words to the documentation. Yes, of course, variables with the SAVE attribute should always be placed in static memory to fulfill the standard requirements. > Regarding -fmax-stack-var-size=n and -fstack-arrays, one also needs to > should point out the implications regarding recursive use, possibly the > effect of an explicit RECURSIVE and Fortran >= 2018. Yes, if we make -frecursive the default this should be documented, along with instructions what to do if the program starts crashing due to running out of stack space. I.e. emphasizing using allocatables, and flashing "Danger Will Robinson" signs around -fmax-stack-var-size and -fno-automatic options that can be used to work around the issue without modifying the program. > Regarding the stack to static handling: I think we currently also print the > message if the user has explicitly given "NON_RECURSIVE" as the flag is > currently binary (recursive - true/false) but it should keep track of > (nonspecified, recursive, non_recursive). Currently the parser doesn't understand NON_RECURSIVE. But even when that is fixed, does it need to be non-binary? It can still be a binary flag, in case it's not specified the flag can be set based on the chosen std flags?