https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98290
Bug ID: 98290 Summary: run-time error with optional character arguments Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: vivekrao4 at yahoo dot com Target Milestone: --- With GNU Fortran (GCC) 11.0.0 20200927 (experimental) on Windows from equation.com, compiling and running the code function c(x1,x2) result(vec) ! return array of present character variable arguments character (len=*) , intent(in), optional :: x1,x2 character (len=10) , allocatable :: vec(:) character (len=10) , allocatable :: vec_(:) integer :: n allocate (vec_(2)) vec = "" if (present(x1)) vec_(1) = x1 if (present(x2)) vec_(2) = x2 n = count([present(x1),present(x2)]) allocate (vec(n)) if (n > 0) vec = vec_(:n) end function c end module util_mod ! program xc use util_mod, only: c implicit none print*,c("girl","boy") end program xc gives Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0xffffffff #1 0xffffffff #2 0xffffffff #3 0xffffffff #4 0xffffffff #5 0xffffffff #6 0xffffffff #7 0xffffffff #8 0xffffffff #9 0xffffffff #10 0xffffffff #11 0xffffffff #12 0xffffffff #13 0xffffffff #14 0xffffffff but gives girl boy with g95 and Intel Fortran.