[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2021-12-09 Thread vivekrao4 at yahoo dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Vivek Rao  changed:

   What|Removed |Added

 CC||vivekrao4 at yahoo dot com

--- Comment #13 from Vivek Rao  ---
Many warnings that I think are spurious for the code

program main
implicit none
character (len=:), allocatable :: words(:)
words = ["dog","cat"]
print*,words
end program main

compiled with gfortran -Wall xalloc_char.f90
using GNU Fortran (GCC) 12.0.0 20211024 (experimental) from equation.com on
Windows gives

xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
Warning: '.words' is used uninitialized [-Wuninitialized]
xalloc_char.f90:1:12:

1 | program main
  |^
note: '.words' was declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.offset' is used uninitialized [-Wuninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].lbound' is used uninitialized [-Wuninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].ubound' is used uninitialized [-Wuninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].lbound' may be used uninitialized
[-Wmaybe-uninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].ubound' may be used uninitialized
[-Wmaybe-uninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].ubound' may be used uninitialized
[-Wmaybe-uninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here
xalloc_char.f90:4:21:

4 | words = ["dog","cat"]
  | ^
Warning: 'words.dim[0].lbound' may be used uninitialized
[-Wmaybe-uninitialized]
xalloc_char.f90:3:42:

3 | character (len=:), allocatable :: words(:)
  |  ^
note: 'words' declared here

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2021-07-01 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

--- Comment #12 from Tobias Burnus  ---
character(len=:), allocatable :: aa(:)
character(len=:), pointer :: pp(:)

allocate(character(len=5) :: aa(5), pp(5))
end



gives with  gfortran -Wall

1 | character(len=:), allocatable :: aa(:)
  |  ^
Warning: ‘.aa’ is used uninitialized [-Wuninitialized]
afoo.f90:2:34:

2 | character(len=:), pointer :: pp(:)
  |  ^
Warning: ‘.pp’ is used uninitialized [-Wuninitialized]



The reason is how dtype is initialized:

  D.3965 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.aa> * 8;
  D.3966 = (sizetype) NON_LVALUE_EXPR <.aa>;
  aa.data = 0B;
  aa.dtype = {.elem_len=(unsigned long) .aa, .rank=1, .type=6};


Later with the alloc, it is correctly set, i.e. it is only an issue for the
initial deallocate state; during allocate:

.aa = 5;
aa.dtype = {.elem_len=(unsigned long) .aa, .rank=1, .type=6};


=> Solution: Don't set .elem_len  if the typespec is expr->ts.deferred)

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2021-06-10 Thread johnsonsr at ornl dot gov via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Seth Johnson  changed:

   What|Removed |Added

 CC||johnsonsr at ornl dot gov

--- Comment #11 from Seth Johnson  ---
I confirm that with both 10.2 and 8.3, the example code prints the erroneous
warning with `-O0` and works as expected (no warning) with `-O1` and higher.

```
$FC "-Wall" -O1 -c ./ftest.f90
```

```fortran
subroutine do_stuff()
character(len=*), parameter :: src = "nope"
character(len=:), allocatable :: dst
dst = src
write(*,*) dst
end subroutine
```

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2021-03-26 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Martin Sebor  changed:

   What|Removed |Added

  Known to fail||10.2.0, 11.0, 4.8.4, 4.9.4,
   ||5.5.0, 6.4.0, 7.2.0, 8.3.0,
   ||9.1.0
   Last reconfirmed|2014-03-22 00:00:00 |2021-3-26
 CC||msebor at gcc dot gnu.org

--- Comment #10 from Martin Sebor  ---
Reconfirming with GCC 11.

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2019-03-23 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

--- Comment #9 from Dominique d'Humieres  ---
The dump-tree-original shows

...
if (name_format != 0B) goto L.1;
name_format = (character(kind=1)[1:.name_format] *) __builtin_malloc (1);
goto L.2;
L.1:;
if (.name_format == 0) goto L.2;
name_format = (character(kind=1)[1:.name_format] *) __builtin_realloc
((void *) name_format, 1);
L.2:;
.name_format = 0;
...

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2019-03-23 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Dominique d'Humieres  changed:

   What|Removed |Added

 CC||adam at aphirst dot karoo.co.uk

--- Comment #8 from Dominique d'Humieres  ---
*** Bug 88455 has been marked as a duplicate of this bug. ***

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2018-12-23 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Dominique d'Humieres  changed:

   What|Removed |Added

 CC||fmartinez at gmv dot com

--- Comment #7 from Dominique d'Humieres  ---
*** Bug 60122 has been marked as a duplicate of this bug. ***

[Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized

2018-07-02 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

janus at gcc dot gnu.org changed:

   What|Removed |Added

Summary|Allocatable-length  |Allocatable-length
   |character var causes bogus  |character var causes bogus
   |warning with -Wall  |warning with
   ||-Wuninitialized

--- Comment #6 from janus at gcc dot gnu.org ---
(In reply to janus from comment #5)
> Related test case:

This is probably a separate problem, since it is also connected to a wrong-code
bug, see PR 86372.