public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-56670-4-wPTUMALhKn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-56670-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670 --- Comment #12 from Tobias Burnus <burnus at gcc dot gnu.org> --- 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)
next prev parent reply other threads:[~2021-07-01 15:33 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-03-20 20:39 [Bug fortran/56670] New: Allocatable-length character var causes bogus warning with -Wall townsend at astro dot wisc.edu 2014-03-22 15:46 ` [Bug fortran/56670] " dominiq at lps dot ens.fr 2015-08-07 20:26 ` mikael at gcc dot gnu.org 2021-03-26 16:51 ` [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized msebor at gcc dot gnu.org 2021-06-10 17:19 ` johnsonsr at ornl dot gov 2021-07-01 15:33 ` burnus at gcc dot gnu.org [this message] 2021-12-10 1:16 ` vivekrao4 at yahoo dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-56670-4-wPTUMALhKn@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).