[Bug fortran/106089] false positives with -Wuninitialized for allocation on assignment
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106089 --- Comment #1 from beliavsky at aol dot com --- I see that the report is a duplicate of some reports listed at https://fortran-lang.discourse.group/t/gfortran-uninitialized-warnings/3838/4 56670 – Allocatable-length character var causes bogus warning with -Wuninitialized 1 91442 – Wrong "may be used uninitialized" warning with allocation on assignment 77504 – [10/11/12/13 Regression] "is used uninitialized" with allocatable string and array constructors
[Bug fortran/106089] New: false positives with -Wuninitialized for allocation on assignment
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106089 Bug ID: 106089 Summary: false positives with -Wuninitialized for allocation on assignment Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: beliavsky at aol dot com Target Milestone: --- For the code implicit none integer, allocatable :: v(:) character(len=1), allocatable :: a(:) a = ["a"] print*, a v = [10,20] print*,v end gfortran -Wall -Wextra xgfortran_warn.f90 gives many incorrect warnings: xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.offset' is used uninitialized [-Wuninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].lbound' is used uninitialized [-Wuninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].ubound' is used uninitialized [-Wuninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].ubound' may be used uninitialized [-Wmaybe-uninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here xgfortran_warn.f90:4:9: 4 | a = ["a"] | ^ Warning: 'a.dim[0].lbound' may be used uninitialized [-Wmaybe-uninitialized] xgfortran_warn.f90:3:37: 3 | character(len=1), allocatable :: a(:) | ^ note: 'a' declared here The output is the same for gfortran 12.0.1 20220213 on Windows from equation.com and gfortran-11 on WSL2. The code combines two codes from a Fortran Discourse discussion https://fortran-lang.discourse.group/t/gfortran-uninitialized-warnings/3838 .
[Bug fortran/31921] New: crash for FUNCTION with RESULT specifier
module mman implicit none private public mskew,nskew contains function nskew() result(y) real :: y(1) call skewm(y) end function nskew ! function mskew() real :: mskew(1) call skewm(mskew) end function mskew ! subroutine skewm(smat) real, intent(out) :: smat(1) smat = 0.0 end subroutine skewm end module mman ! program mtst use mman, only: mskew,nskew implicit none print*,"(1) calling nskew" print*,nskew() print*,"(2) calling mskew" print*,mskew() print*,"(3) done" end program mtst Compiling with mingw gfortran 20070506 with the default options gives the incorrect warning message xfunc_bug.f90: In function 'mskew': xfunc_bug.f90:13: warning: Function does not return a value and at run time the output is (1) calling nskew 0.00 (2) calling mskew -- Summary: crash for FUNCTION with RESULT specifier Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: beliavsky at aol dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31921
[Bug fortran/31867] function result with character LEN computed at run time
--- Comment #4 from beliavsky at aol dot com 2007-05-09 15:27 --- (In reply to comment #2) > I get: > words = 'two three' > On x86-64-gnu/linux with latest 4.3 > I wonder if this is one that we recently fixed. Can you try with a more > recent > build? Using Mingw 20070506, the problem persists. The behavior of the compiled program is erratic. Running the compiled program in one Windows console (command line) I get different "garbage" characters appended to the correct output than when running it in a different Windows console. Running the program repeatedly in the same console gives the same results. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31867
[Bug fortran/31867] New: function result with character LEN computed at run time
The program module util_mod implicit none contains function join(words,sep) result(str) ! trim and concatenate a vector of character variables, ! inserting sep between them character (len=*), intent(in):: words(:),sep character (len=(size(words)-1)*len(sep) + sum(len_trim(words))) :: str integer :: i,nw nw = size(words) str = "" if (nw < 1) then return else str = words(1) end if do i=2,nw str = trim(str) // sep // words(i) end do end function join end module util_mod ! program xjoin use util_mod, only: join implicit none character (len=5) :: words(2) = (/"two ","three"/) write (*,"(1x,'words = ',a)") "'"//join(words," ")//"'" end program xjoin gives words = 'two threeg9' but I think it should give words = 'two three' gfortran -v says Using built-in specs. Target: i386-pc-mingw32 Configured with: ../trunk/configure --prefix=/mingw --enable-languages=c,fortran,c++,objc,obj-c++ --with-gmp=/home/coudert/local --disable-nls --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads --build=i386-pc-mingw32 --disable-shared --enable-libgomp Thread model: win32 gcc version 4.3.0 20070406 (experimental) -- Summary: function result with character LEN computed at run time Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: beliavsky at aol dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31867
[Bug fortran/31672] New: Not Implemented: Initialization of overlapping variables
This feature is used "classic" Fortran 77 libraries such as Starpac, as mentioned in comp.lang.fortran on 23-Apr-2007 . c:\fortran> type d1mach.f90 function d1mach(i) implicit none double precision d1mach,dmach(5) integer i,large(4),small(4) equivalence ( dmach(1), small(1) ) equivalence ( dmach(2), large(1) ) data small(1),small(2) / 0, 1048576/ data large(1),large(2) /-1,2146435071/ d1mach = 0.0d0 end function d1mach c:\fortran> gfortran -c -v d1mach.f90 Using built-in specs. Target: i386-pc-mingw32 Configured with: ../trunk/configure --prefix=/mingw --enable-languages=c,fortran,c++,objc,obj-c++ --with-gmp=/home/coudert/local --disable-nls --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads --build=i386-pc-mingw32 --disable-shared --enable-libgomp Thread model: win32 gcc version 4.3.0 20070406 (experimental) c:/programs/gfortran/bin/../libexec/gcc/i386-pc-mingw32/4.3.0/f951.exe d1mach.f90 -quiet -dumpbase d1mach.f90 -mtune=i386 -auxbase d1mach -version -fintrinsic-modules-path c:/programs/gfortran/bin/../lib/gcc/i386-pc-mingw32/4.3.0/finclude -o C:\DOCUME~1\vrao\LOCALS~1\Temp/cchM3Bia.s GNU F95 version 4.3.0 20070406 (experimental) (i386-pc-mingw32) compiled by GNU C version 4.3.0 20070406 (experimental). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 d1mach.f90: In function 'd1mach': d1mach.f90:1: fatal error: gfc_todo: Not Implemented: Initialization of overlapping variables compilation terminated. -- Summary: Not Implemented: Initialization of overlapping variables Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: beliavsky at aol dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31672