* Re: 'MEM[(struct m *)&s + 56B]' may be used uninitialized in this function
@ 2018-06-14 14:59 Dominique d'Humières
2018-06-15 0:11 ` Andrew Benson
0 siblings, 1 reply; 3+ messages in thread
From: Dominique d'Humières @ 2018-06-14 14:59 UTC (permalink / raw)
To: abenson; +Cc: gfortran
Hi Andrew,
I think this a duplicate of pr86117 and probably others. The warnings come from the middle-end, but I don’t know if the problem comes from gfortran or not.
Cheers,
Dominique
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'MEM[(struct m *)&s + 56B]' may be used uninitialized in this function
2018-06-14 14:59 'MEM[(struct m *)&s + 56B]' may be used uninitialized in this function Dominique d'Humières
@ 2018-06-15 0:11 ` Andrew Benson
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Benson @ 2018-06-15 0:11 UTC (permalink / raw)
To: Dominique d'Humières; +Cc: gfortran
Hi Dominique,
Thanks - that does look like the same problem. I'll add myself to the CC list
for that PR.
Cheers,
Andrew
On Thursday, June 14, 2018 3:40:52 PM PDT Dominique d'Humières wrote:
> Hi Andrew,
>
> I think this a duplicate of pr86117 and probably others. The warnings come
> from the middle-end, but I don’t know if the problem comes from gfortran or
> not.
>
> Cheers,
>
> Dominique
--
* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
* Galacticus: https://bitbucket.org/abensonca/galacticus
^ permalink raw reply [flat|nested] 3+ messages in thread
* 'MEM[(struct m *)&s + 56B]' may be used uninitialized in this function
@ 2018-06-14 8:06 Andrew Benson
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Benson @ 2018-06-14 8:06 UTC (permalink / raw)
To: fortran
With gfortran 8.0.1 the following code (reduced from a much larger code, so
there are obvious things wrong with it):
module mtc
type :: t
integer, allocatable, dimension(:) :: a
end type t
type :: m
type(t), allocatable, dimension(:) :: fs
end type m
contains
subroutine ap(s,ps)
class(m), intent(inout) :: s
type(t), dimension(:), allocatable, intent(inout) :: ps
ps(:)=[t([0]),t([0])]
end subroutine ap
function rcp() result(s)
type(m) :: s
type(t), allocatable, dimension(:) :: fs
type(t), dimension(:), allocatable :: aps
allocate(fs(2))
s=m(fs)
call ap(s,aps)
end function rcp
end module mtc
gives the following when compiled:
$ gfortran -c 059.F90 -O1 -Wall
059.F90:9:17:
subroutine ap(s,ps)
1
Warning: Unused dummy argument 's' at (1) [-Wunused-dummy-argument]
059.F90:19:0:
s=m(fs)
Warning: 'MEM[(struct m *)&s + 48B]' may be used uninitialized in this
function [-Wmaybe-uninitialized]
059.F90:19:0: Warning: 'MEM[(struct m *)&s + 56B]' may be used uninitialized
in this function [-Wmaybe-uninitialized]
059.F90:19:0: Warning: 'fs.span' may be used uninitialized in this function [-
Wmaybe-uninitialized]
I can probably figure out what's causing the "may be used uninitialized" in
this reduced case, but I wondered if the:
'MEM[(struct m *)&s + 48B]'
is as intended, or if this should be the name of some member variable in type
"m" instead?
(The first warning, about the unused dummy argument, is easily fixed of course,
but if I remove the dummy argument the maybe-uninitialized warning goes away.)
-Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-14 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-14 14:59 'MEM[(struct m *)&s + 56B]' may be used uninitialized in this function Dominique d'Humières
2018-06-15 0:11 ` Andrew Benson
-- strict thread matches above, loose matches on Subject: below --
2018-06-14 8:06 Andrew Benson
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).