<div dir="ltr">In my experience, "<span style="font-size:12.8px">-Wmaybe-uninitialized" is a great way to generate false positive compiler warnings and nothing else.</span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Jeff</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 7, 2016 at 11:46 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
src/sys/classes/bag/f2003-src/fsrc/bagenum.F has the code fragment<br>
<br>
Subroutine PetscBagRegisterEnum(bag,addr,FArray,def,n,h,ierr)<br>
use,intrinsic :: iso_c_binding<br>
implicit none<br>
<br>
PetscBag bag<br>
character(*) n,h<br>
character(*) FArray(*)<br>
PetscEnum :: def<br>
PetscErrorCode,intent(out) :: ierr<br>
PetscReal addr(*)<br>
<br>
Type(C_Ptr),Dimension(:),Pointer :: CArray<br>
character(kind=c_char),pointer :: nullc => null()<br>
PetscInt :: i,Len<br>
Character(kind=C_char,len=256),Dimension(:),Pointer::list1<br>
<br>
do i=1,256<br>
if (len_trim(Farray(i)) .eq. 0) then<br>
Len = i-1<br>
goto 100<br>
endif<br>
if (len_trim(Farray(i)) .gt. 255) then<br>
ierr = PETSC_ERR_ARG_OUTOFRANGE<br>
return<br>
endif<br>
enddo<br>
ierr = PETSC_ERR_ARG_OUTOFRANGE<br>
return<br>
<br>
100 continue<br>
<br>
Allocate(list1(Len),stat=ierr);<br>
Allocate(CArray(Len+1),stat=ierr)<br>
do i=1,Len<br>
list1(i) = trim(FArray(i))//C_NULL_CHAR<br>
enddo<br>
<br>
CArray = (/(c_loc(list1(i)),i=1,Len),c_loc(nullc)/)<br>
call PetscBagRegisterEnumPrivate(bag,addr,CArray,def,n,h,ierr)<br>
DeAllocate(CArray)<br>
DeAllocate(list1)<br>
End Subroutine<br>
<br>
which produces the following warning with one Fortran compiler:<br>
<br>
/Users/petsc/petsc.clone-4/src/sys/objects/f2003-src/fsrc/optionenum.F:35:0:<br>
<br>
CArray = (/(c_loc(list1(i)),i=1,Len),c_loc(nullc)/)<br>
^<br>
Warning: 'list1.data' may be used uninitialized in this function [-Wmaybe-uninitialized]<br>
<br>
Do any Fortran programmers know if the code is correct or if this is an incorrect warning from the compiler?<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>
</div>