------- Comment #11 from tkoenig at gcc dot gnu dot org  2009-09-12 14:00 
-------
(In reply to comment #10)

> It doesn't work if the  3rd dimension is > 2
> The test case only shows the array shape.
> It should fill the sample arrays and
> compares.

The test case is:

! { dg-do run }
program main
   use iso_c_binding, only: c_ptr, c_loc, c_f_pointer
   implicit none
   integer, dimension(2,1,2), target :: table
   table = reshape ( (/ 1,2,-1,-2/), (/2,1,2/))
   call set_table (c_loc (table))
contains
   subroutine set_table (cptr)
     type(c_ptr), intent(in) :: cptr
     integer, dimension(:,:,:), pointer :: table_tmp
     call c_f_pointer (cptr, table_tmp, (/2,1,2/))
     if (any(table_tmp /= table)) call abort
     ! ^^^^^^^^^^^^^^^^^^^^^^
     ! comparison happens here
   end subroutine set_table
end program main

Output for the original test case is:

$ gfortran original.f90
$ ./a.out
In:   1  2  3  4  5  6 -1 -2 -3 -4 -5 -6
Tmp:  1  2  3  4  5  6 -1 -2 -3 -4 -5 -6
Out:  1  2  3  4  5  6 -1 -2 -3 -4 -5 -6


Do you have a failing test case?  If so, please
post it.  Are you using the wrong libraries, possibly?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40962

Reply via email to