[Bug fortran/97009] Inlining with non-standard selected_int_kind leads to errors

2020-09-10 Thread pvitt at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97009

--- Comment #1 from Peter Vitt  ---
I forgot to mention that we were able to reproduce this also with 10.1.0 and
9.3.0. In case this is of any help...

[Bug fortran/97009] New: Inlining with non-standard selected_int_kind leads to errors

2020-09-10 Thread pvitt at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97009

Bug ID: 97009
   Summary: Inlining with non-standard selected_int_kind leads to
errors
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pvitt at posteo dot de
  Target Milestone: ---

Created attachment 49207
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49207=edit
Minimum working example to reproduce the problem.

We ran into a problem that I stripped down to a minimal working example (see
attachment). 

When the MWE is compiled with `gfortran -O1 2269_mwe.f90`, it produces the
expected output

 Level3  treeID 0
 Level2  treeID 1
 Level1  treeID 9

When it is compiled with O2, it fails:

 Level3  treeID   140732851705864
 Level2  treeID   140732851705352
 Level1  treeID4545064992

When the line

integer, parameter :: long_k = selected_int_kind(15)

is changed to

integer, parameter :: long_k = selected_int_kind(9)

it works with O1 and O2.

We stumbled over this when some unit tests failed after we activated LTO. Our
first guess was that LTO stumbles over the elemental function (which tem_pathOf
was before I stripped it down). However, while creating the MWE, we ended up
reproducing the behavior also without LTO, but the called function in the same
file. And as it disappears with O1, it seems to be related to inlining in
general.

[Bug fortran/87043] maybe-uninitialized warning for initialized variable

2018-08-22 Thread pvitt at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87043

--- Comment #2 from Peter Vitt  ---
Oh, I see your point. But then still the question is why this warning is not
shown when compiling with -Og.

[Bug fortran/87043] New: maybe-uninitialized warning for initialized variable

2018-08-21 Thread pvitt at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87043

Bug ID: 87043
   Summary: maybe-uninitialized warning for initialized variable
   Product: gcc
   Version: 8.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pvitt at posteo dot de
  Target Milestone: ---

We have a MWE that provokes a "may be uninitialized" warning despite the value
being initialized in all cases. Additionally, this warning is only created with
-O[1,2,3,s,fast}, but not with -O{g}. The gcc is from Arch Linux.

$ gfortran -v -save-temps -O3 -Wmaybe-uninitialized uninitialized.f90
Driving: gfortran -v -save-temps -O3 -Wmaybe-uninitialized uninitialized.f90 -l
gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 8.1.1 20180531 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-Wmaybe-uninitialized'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/f951 uninitialized.f90 -quiet -dumpbase
uninitialized.f90 -mtune=generic -march=x86-64 -auxbase uninitialized -O3
-Wmaybe-uninitialized -version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/finclude -o uninitialized.s
GNU Fortran (GCC) version 8.1.1 20180531 (x86_64-pc-linux-gnu)
compiled by GNU C version 8.1.1 20180531, GMP version 6.1.2, MPFR
version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 8.1.1 20180531 (x86_64-pc-linux-gnu)
compiled by GNU C version 8.1.1 20180531, GMP version 6.1.2, MPFR
version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
uninitialized.f90:20:0:

   max_err_len = maxval(len_trim(error_messages))

Warning: ‘error_messages.dim[0].ubound’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
[stripped assembler output...]


$ cat uninitialized.f90
module m
  implicit none
  integer, parameter :: error_buflen = 80
  integer :: world_rank, world_size

contains

  subroutine test()
character(len=error_buflen), allocatable :: error_messages(:)
integer :: allocstat, max_err_len

max_err_len = 0

if (world_rank == 0 ) then
  allocate(error_messages(world_size), stat=allocstat)
else
  allocate(error_messages(0))
end if
if (world_rank == 0) then
  max_err_len = maxval(len_trim(error_messages))
end if
if (max_err_len > error_buflen-10) then
  write(*,'(a)') 'Note...'
end if

  end subroutine test

end module

program uninitialized
  use m

  implicit none

  read(*,*) world_rank
  world_size = 2

  call test()

end program