[Bug fortran/83622] [8 Regression] Wrong code with derived type and -fopenmp

paul.richard.thomas at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Dec 30 14:00:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83622

--- Comment #4 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> ---
I can see what is happening: During the allocate, we have

    check.dim[0].lbound = 1;
    check.dim[0].ubound = 4;
    check.dim[0].stride = 1;
    check.offset = -1;

but no sign of the span field being set.

Later failing array references have:
              _gfortran_transfer_character_write (&dt_parm.4,
&((struct t_check *) D.3791 + (sizetype) ((S.5 * D.3795 + D.3792) *
check.span))->fnct, 2);

and so it should be easy enough to find out what is wrong. This works
as expected:

! PR83622
program gfcbug144
  implicit none
  type t_check
     character(len=2) :: fnct = ''
  end type t_check
  character(len=*), parameter :: FNCT_EMISS  = 'a'
  character(len=*), parameter :: FNCT_MNW    = 'b'
  character(len=*), parameter :: FNCT_FG     = 'c'
  character(len=*), parameter :: FNCT_ALWAYS = 'd'
  type(t_check),    pointer   :: check(:)    => null()
  type(t_check),    allocatable, target   :: check2(:)

  integer :: n, i
  allocate (check2(4))
  check2(1)% fnct = FNCT_EMISS
  check2(2)% fnct = FNCT_MNW
  check2(3)% fnct = FNCT_FG
  check2(4)% fnct = FNCT_ALWAYS

  check => check2

  n = size (check)
  do i=1, n
     print*, "i =", i, "fnct(i) = '", check(i)%fnct, "'"
  end do
  print*, "fnct = '", check(1:n)%fnct, "'"
  print*, "equal =", check(1:n)%fnct == FNCT_MNW
  print*, "count =", count(check(1:n)%fnct == FNCT_MNW)
end program gfcbug144

It's the pointer allocation that is screwed up with openmp.

Cheers

Paul


On 30 December 2017 at 12:05, pault at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83622
>
> Paul Thomas <pault at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
>
> --- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
> (In reply to Jakub Jelinek from comment #2)
>> Yes, indeed it is caused by r251949.
>
> OK - I have to head off to my sisters for New Year's Eve. I will get onto it
> when I return.
>
> Paul
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.


More information about the Gcc-bugs mailing list