public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106089] New: false positives with -Wuninitialized for allocation on assignment
@ 2022-06-26 11:21 beliavsky at aol dot com
  2022-06-26 11:25 ` [Bug fortran/106089] " beliavsky at aol dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: beliavsky at aol dot com @ 2022-06-26 11:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106089
           Summary: false positives with -Wuninitialized for allocation on
                    assignment
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: beliavsky at aol dot com
  Target Milestone: ---

For the code 

implicit none
integer, allocatable :: v(:)
character(len=1), allocatable :: a(:)
a = ["a"]
print*, a
v = [10,20]
print*,v
end

gfortran -Wall -Wextra xgfortran_warn.f90

gives many incorrect warnings:

xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.offset' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].lbound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].ubound' is used uninitialized [-Wuninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:

    3 | character(len=1), allocatable :: a(:)
      |                                     ^
note: 'a' declared here
xgfortran_warn.f90:4:9:

    4 | a = ["a"]
      |         ^
Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized]
xgfortran_warn.f90:3:37:

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


The output is the same for gfortran 12.0.1 20220213 on Windows from
equation.com
and gfortran-11 on WSL2. The code combines two codes from a Fortran Discourse
discussion
https://fortran-lang.discourse.group/t/gfortran-uninitialized-warnings/3838 .

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-02 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26 11:21 [Bug fortran/106089] New: false positives with -Wuninitialized for allocation on assignment beliavsky at aol dot com
2022-06-26 11:25 ` [Bug fortran/106089] " beliavsky at aol dot com
2022-06-27 19:39 ` anlauf at gcc dot gnu.org
2022-07-02 17:53 ` kargl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).