public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56670] New: Allocatable-length character var causes bogus warning with -Wall
@ 2013-03-20 20:39 townsend at astro dot wisc.edu
  2014-03-22 15:46 ` [Bug fortran/56670] " dominiq at lps dot ens.fr
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: townsend at astro dot wisc.edu @ 2013-03-20 20:39 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

             Bug #: 56670
           Summary: Allocatable-length character var causes bogus warning
                    with -Wall
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: townsend@astro.wisc.edu


Compiling this short test case with the -Wall option:

program uninit_test

  implicit none

  character(LEN=:), allocatable :: name_format

  name_format = ''

end program uninit_test

...causes the following bogus warning:

uninit_test.f90: In function ‘uninit_test’:
uninit_test.f90:7:0: warning: ‘.name_format’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
   name_format = ''
 ^

(Note also that the warning arises in the main program, and not in a function
as the message suggests).

gfortran -v:

Using built-in specs.
COLLECT_GCC=/Applications/madsdk/bin/gfortran.exec
COLLECT_LTO_WRAPPER=/Applications/madsdk/libexec/gcc/x86_64-apple-darwin11.4.2/4.8.0/lto-wrapper
Target: x86_64-apple-darwin11.4.2
Configured with: ./configure CC='gcc -D_FORTIFY_SOURCE=0'
--build=x86_64-apple-darwin11.4.2 --prefix=/Applications/madsdk
--with-gmp=/Applications/madsdk --with-mpfr=/Applications/madsdk
--with-mpc=/Applications/madsdk --enable-languages=c,c++,fortran
--disable-multilib
Thread model: posix
gcc version 4.8.0 20130314 (experimental) (GCC)
>From gcc-bugs-return-417997-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Mar 20 22:00:35 2013
Return-Path: <gcc-bugs-return-417997-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20231 invoked by alias); 20 Mar 2013 22:00:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20154 invoked by uid 48); 20 Mar 2013 22:00:27 -0000
From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/53323] assertion failure on indefinite array of controlled objects and storage pools
Date: Wed, 20 Mar 2013 22:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ada
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ebotcazou at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-53323-4-G6rqU3VuXd@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-53323-4@http.gcc.gnu.org/bugzilla/>
References: <bug-53323-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-03/txt/msg01438.txt.bz2
Content-length: 349


http://gcc.gnu.org/bugzilla/show_bug.cgi?idS323

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-03-20 22:00:26 UTC ---
> Must have been a recent fix, cos it failed with gcc version 4.8.0 20130309
> (experimental) [trunk revision 196573] (GCC)!

Sort of, we now disable the front-end assertions on release branches.


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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wall
  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 ` dominiq at lps dot ens.fr
  2015-08-07 20:26 ` mikael at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-03-22 15:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56670

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-03-22
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from 4.6 to trunk (4.9).


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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wall
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-08-07 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
Possibly related: PR60500


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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized
  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 ` msebor at gcc dot gnu.org
  2021-06-10 17:19 ` johnsonsr at ornl dot gov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-26 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> 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 <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11.

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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized
  2013-03-20 20:39 [Bug fortran/56670] New: Allocatable-length character var causes bogus warning with -Wall townsend at astro dot wisc.edu
                   ` (2 preceding siblings ...)
  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
  2021-12-10  1:16 ` vivekrao4 at yahoo dot com
  5 siblings, 0 replies; 7+ messages in thread
From: johnsonsr at ornl dot gov @ 2021-06-10 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

Seth Johnson <johnsonsr at ornl dot gov> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johnsonsr at ornl dot gov

--- Comment #11 from Seth Johnson <johnsonsr at ornl dot gov> ---
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
```

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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized
  2013-03-20 20:39 [Bug fortran/56670] New: Allocatable-length character var causes bogus warning with -Wall townsend at astro dot wisc.edu
                   ` (3 preceding siblings ...)
  2021-06-10 17:19 ` johnsonsr at ornl dot gov
@ 2021-07-01 15:33 ` burnus at gcc dot gnu.org
  2021-12-10  1:16 ` vivekrao4 at yahoo dot com
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-07-01 15:33 UTC (permalink / raw)
  To: gcc-bugs

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)

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

* [Bug fortran/56670] Allocatable-length character var causes bogus warning with -Wuninitialized
  2013-03-20 20:39 [Bug fortran/56670] New: Allocatable-length character var causes bogus warning with -Wall townsend at astro dot wisc.edu
                   ` (4 preceding siblings ...)
  2021-07-01 15:33 ` burnus at gcc dot gnu.org
@ 2021-12-10  1:16 ` vivekrao4 at yahoo dot com
  5 siblings, 0 replies; 7+ messages in thread
From: vivekrao4 at yahoo dot com @ 2021-12-10  1:16 UTC (permalink / raw)
  To: gcc-bugs

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

Vivek Rao <vivekrao4 at yahoo dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vivekrao4 at yahoo dot com

--- Comment #13 from Vivek Rao <vivekrao4 at yahoo dot com> ---
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

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

end of thread, other threads:[~2021-12-10  1:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-12-10  1:16 ` vivekrao4 at yahoo dot com

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).