http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57834
Bug ID: 57834
Summary: C_F_POINTER regression(-std): accepts only explicit-
and assumed-size arrays for FPTR when SHAPE is present
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jwmwalrus at gmail dot com
The following compiles with gfortran 4.8, but fails with gfortran 4.9:
program main
use iso_c_binding
use iso_fortran_env
implicit none
interface
function strerror(errno) bind(C, NAME = 'strerror')
import
type(C_PTR) :: strerror
integer(C_INT), value :: errno
end function
end interface
integer :: i
type(C_PTR) :: cptr
character(KIND=C_CHAR), pointer :: str(:)
cptr = strerror(INT(42, KIND = C_INT))
call C_F_POINTER(cptr, str, [255])
do i = 1, SIZE(str)
if (str(i) == C_NULL_CHAR) exit
write (ERROR_UNIT, '(A1)', ADVANCE = 'NO') str(i:i)
enddo
write (ERROR_UNIT, '(1X)')
end program main
The actual error, which only happens when -std=f2003 or -std=f2008 is used, is
highly inconsistent: FPTR must be pointer and when SHAPE is present, it must
also be a deferred-shape array one. The error is:
...:~$ gfortran-4.9 -std=f2008 test_cfpointer.f90
test_cfpointer.f90:21.27:
call C_F_POINTER(cptr, str, [255])
1
Error: TS 29113: Noninteroperable array FPTR at (1) to C_F_POINTER: Only
explicit-size and assumed-size arrays are interoperable
The system info is:
...:~$ ll `which gfortran-4.9` && /usr/lib/gcc-snapshot/bin/gfortran -v &&
apt-cache policy gfortran-4.8 gcc-snapshot && lsb_release -rd
lrwxrwxrwx 1 root staff 34 Jul 5 12:58 /usr/local/bin/gfortran-4.9 ->
/usr/lib/gcc-snapshot/bin/gfortran*
Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20130620-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id
--disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-snap-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-snap-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-snap-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --disable-werror
--enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.0 20130620 (experimental) [trunk revision 200244] (Debian
20130620-1)
gfortran-4.8:
Installed: 4.8.1-5
Candidate: 4.8.1-5
Version table:
*** 4.8.1-5 0
200 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
100 /var/lib/dpkg/status
4.8.1-2 0
500 http://ftp.us.debian.org/debian/ testing/main amd64 Packages
gcc-snapshot:
Installed: 20130620-1
Candidate: 20130620-1
Version table:
*** 20130620-1 0
200 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
100 /var/lib/dpkg/status
Description: Debian GNU/Linux testing (jessie)
Release: testing