File: pointer_remapping_10.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (46 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
! { dg-do run }
! { dg-options "-fcheck=all" }
!
! PR fortran/71194
!
! Contributed by T Kondic
!
program ice
implicit none
integer, parameter :: pa=10, pb=20
complex, target :: a(pa*pb)
real, pointer:: ptr(:,:) =>null()
integer :: i, j, cnt
logical :: negative

  do i = 1, size(a)
    a(i) = cmplx(i,-i)
  end do

  ! Was ICEing before with bounds checks
  ptr(1:pa*2,1:pb) => conv2real(a)

  negative = .false.
  cnt = 1
  do i = 1, ubound(ptr,dim=2)
    do j = 1, ubound(ptr,dim=1)
      if (negative) then
        if (-cnt /= ptr(j, i)) STOP 1
        cnt = cnt + 1
        negative = .false.
      else
        if (cnt /= ptr(j, i)) STOP 2
        negative = .true.
      end if
    end do 
  end do

contains
  function conv2real(carr)
    use, intrinsic :: iso_c_binding
    ! returns real pointer to a complex array
    complex, contiguous, intent(inout), target  :: carr(:)
    real,contiguous,pointer :: conv2real(:)
    call c_f_pointer(c_loc(carr),conv2real,[size(carr)*2])
  end function conv2real
end program