This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/38813] ICE with C_LOC(array)
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jan 2009 13:34:35 -0000
- Subject: [Bug fortran/38813] ICE with C_LOC(array)
- References: <bug-38813-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from burnus at gcc dot gnu dot org 2009-01-12 13:34 -------
> I think NAG f95 is right by rejecting it with:
> Error: line 9: The argument to C_LOC must not be an array pointer
Or maybe not: "15.1.2.5 C_LOC(X)" has for the result value:
"(2) If X is an array data entity, the result is determined as if C_PTR were a
derived type containing a scalar pointer component PX of the type and type
parameters of X and the pointer assignment of CPTR%PX to the first element of X
were executed"
The example is still wrong as it fails (1c):
"Argument. X shall either
(1) have interoperable type and type parameters and be
(a) a variable that has the TARGET attribute and is interoperable,
(b) an allocated allocatable variable that has the TARGET attribute and is
not an array of zero size, or
(c) an associated scalar pointer, or
(2) be a nonpolymorphic scalar, have no length type parameters, and be"
Is seems as if
a) no-pointer, no-allocatable arrays
b) allocatable arrays (allocated without empty size)
are allowed. Thus the following programs should be valid -- and it also
compiles with NAG f95:
use iso_c_binding
implicit none
type tY
REAL (KIND=c_float), dimension(5) :: y_fptr = 5
REAL (KIND=c_float), dimension(:), allocatable :: y_fptr2
Integer (Kind=c_int) :: ny = 0
end type
type(ty), target :: y_f
type(c_ptr) :: y_cptr
y_cptr = c_loc(y_f%y_fptr)
allocate(y_f%y_fptr2(2))
y_cptr = c_loc(y_f%y_fptr2)
end
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic, ice-on-valid-
| |code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38813