[Bug fortran/97977] New: Fortran deferred length strings incompatible with OMP

2020-11-24 Thread poorasmith at protonmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97977

Bug ID: 97977
   Summary: Fortran deferred length strings incompatible with OMP
   Product: gcc
   Version: 7.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: poorasmith at protonmail dot com
  Target Milestone: ---

gfortran does not correctly handle deferred length strings in OMP loops. 
Minimal example program:

program test_OMPStr
  implicit none

  integer :: indx
  character(len=:), allocatable :: string1, string2

  !$omp parallel do default(none) &
  !$omp private(indx, string1, string2) &
  !$omp num_threads(2)
  do indx = 1, 5
string1 = ''
string2 = ''
string1 = 'abc'
string2 = 'abc'
if (string1 .ne. string2) then
  write(*,*) 'string mismatch on indx', indx
  stop
end if
  end do
  !$omp end parallel do
end program test_OMPStr

This program will stop at a pseudo random index.  If num_threads(1) is used the
program works as expected.  If fixed length strings are used the program works
as expected.

[Bug fortran/100478] New: Type Pointer Segfaults

2021-05-07 Thread poorasmith at protonmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100478

Bug ID: 100478
   Summary: Type Pointer Segfaults
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: poorasmith at protonmail dot com
  Target Milestone: ---

The following program segfaults (11.1.0 and 9.3.0) with "option 2" (pointer
referencing itself) but works fine with "option 1" (direct reference).  Both
options work fine with 7.5.0.

program fortranNull
  implicit none

  type myType
type(myType), pointer, dimension(:) :: someType => null()
  end type myType

  type(myType),  target, dimension(1) :: typeTarget
  type(myType), pointer, dimension(:) :: typePointer

  character(len=1) :: arg

  call get_command_argument(1, arg) 

  if (arg .eq. '1') then
write(*,*) 'Direct Assignment'
typePointer => typeTarget
typePointer => typeTarget(1)%someType
  else if (arg .eq. '2') then
write(*,*) 'Referenced Assignment'
typePointer => typeTarget
typePointer => typePointer(1)%someType
  else
write(*,*) 'expected either "1" or "2" command line argument'
  end if

end program fortranNull