https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123903

            Bug ID: 123903
           Summary: Usage of unallocated `character` variable in `//` does
                    not trigger warning
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

This is not a bug report, but rather a suggestion for enhancing the runtime
warnings. 
The following code: 

```
character(:), allocatable :: s
s = s // 'a' ! intentionally used unallocated in hrs
print *, s
end
```

Never triggers any errors in the Fortran runtime, with any combination of
runtime checks (all, mem, bounds, pointer). 

Can be checked here: https://godbolt.org/z/xWcn5YqPT

(Of course -Wmaybe-uninitialize does catch that properly at compile time). 

A lengthy explanation of why unallocated character variables are not valid in
concatenation was submitted here: https://github.com/fortran-lang/fpm/pull/1229

That is why I think it may be worthwhile to also notice the gfortran team about
it.

Thank you,
Federico

Reply via email to