# Can I guarantee \`allocatable\` variables to start out not allocated?

**URL:** <https://fortran-lang.discourse.group/t/can-i-guarantee-allocatable-variables-to-start-out-not-allocated/8865>\
**Category:** Help\
**Created:** [November 21, 2024, 5:13pm UTC](https://fortran-lang.discourse.group/t/can-i-guarantee-allocatable-variables-to-start-out-not-allocated/8865 "2024-11-21T17:13:03Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![septc](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/septc/32/77_2.png) [@septc](https://fortran-lang.discourse.group/u/septc)\
**Post date:** [November 23, 2024, 8:24am UTC](https://fortran-lang.discourse.group/t/can-i-guarantee-allocatable-variables-to-start-out-not-allocated/8865/6 "2024-11-23T08:24:11Z")

</div>

I’ve come across the following question on StackOverflow, which may be related to the unexpected behavior of `allocatable` by Gfortran (linked in the above post, which is still reproducible with Gfortran-14 on Godbolt). Indeed, this may be a bug of the option `-fmax-stack-var-size` itself, though not sure about details.

> <https://stackoverflow.com/questions/79211542/function-wrongly-returning-empty-character-string-if-allocated-on-the-heap>

EDIT: Here is the man page for this option.

- [-fmax-stack-var-size](https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html#index-fmax-stack-var-size)

> This option currently only affects local arrays declared with constant bounds, and may not apply to all character variables.

Also a previous thread on this option (not related to the above issue):

- [-frecursive .vs. fmax-stack-var-size .vs. -unlimit -s](https://fortran-lang.discourse.group/t/frecursive-vs-fmax-stack-var-size-vs-unlimit-s/2970)

---

_[View the full topic](https://fortran-lang.discourse.group/t/can-i-guarantee-allocatable-variables-to-start-out-not-allocated/8865)._
