From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A5F28388A418; Thu, 1 Jul 2021 15:33:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5F28388A418 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized Date: Thu, 01 Jul 2021 15:33:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2021 15:33:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56670 --- Comment #12 from Tobias Burnus --- character(len=3D:), allocatable :: aa(:) character(len=3D:), pointer :: pp(:) allocate(character(len=3D5) :: aa(5), pp(5)) end gives with gfortran -Wall 1 | character(len=3D:), allocatable :: aa(:) | ^ Warning: =E2=80=98.aa=E2=80=99 is used uninitialized [-Wuninitialized] afoo.f90:2:34: 2 | character(len=3D:), pointer :: pp(:) | ^ Warning: =E2=80=98.pp=E2=80=99 is used uninitialized [-Wuninitialized] The reason is how dtype is initialized: D.3965 =3D (bitsizetype) (sizetype) NON_LVALUE_EXPR <.aa> * 8; D.3966 =3D (sizetype) NON_LVALUE_EXPR <.aa>; aa.data =3D 0B; aa.dtype =3D {.elem_len=3D(unsigned long) .aa, .rank=3D1, .type=3D6}; Later with the alloc, it is correctly set, i.e. it is only an issue for the initial deallocate state; during allocate: .aa =3D 5; aa.dtype =3D {.elem_len=3D(unsigned long) .aa, .rank=3D1, .type=3D6}; =3D> Solution: Don't set .elem_len if the typespec is expr->ts.deferred)=