Internal compiler error when passing TYPE(C_PTR) argument

I’m getting an error for the following code using
pgf90 8.0-1 64-bit target on x86-64 Linux -tp k8-64e

FUNCTION test(start)
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
TYPE(C_PTR), VALUE, INTENT(IN) :: start
INTEGER :: test
test = 1
END FUNCTION test

It gives me the error:

PGF90-S-0000-Internal compiler error. unrec dtype in cp_iregarg 30 (testfun.f90: 2)
pgf90-Fatal-/usr/pgi/8.0-1/linux86-64/8.0-1/bin/pgf902 TERMINATED by signal 11
Arguments to /usr/pgi/8.0-1/linux86-64/8.0-1/bin/pgf902
/usr/pgi/8.0-1/linux86-64/8.0-1/bin/pgf902 /tmp/pgf90tWed5_dxOktZ.ilm -fn testfun.f90 -opt 1 -terse 1 -inform warn -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 70 0x8000 -x 122 1 -quad -x 59 4 -x 59 4 -tp k8-64e -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 124 1 -cmdline ‘+pgf90 testfun.f90 -c’ -asm /tmp/pgf90BWedrx3uy6_Y.s

gfortran, g95, ifort, and sunf95 all compile the code.

Hi Breitenfeld,

Thank you for the report. This is a compiler problem where we’re not handling the “VALUE” attribute correctly with “TYPE(C_PTR)”. We’ve created a technical problem report (TPR#15464) and sent it to our compiler engineers.

Hopefully we’ll have this fixed shortly. In the meantime, you’ll need to pass ‘start’ by reference (i.e. remove the “VALUE” attribute.). In your C code, you will need to do something like the following in order to pass the pointer by reference:

int test(int *x);
int main() {
     int a;
     int *pa;
     a = 5;
     pa = &a;
     test(&pa);
     printf("a = %d\n",a);
}

Best regards,
Mat

Hi Breitenfeld,

TPR#15464 has been fixed as of PGI 8.0-3.

Thanks!
Mat