This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49110] New: Deferred-length character result triggers (false positive) error for pure procedures
- From: "jwmwalrus at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 22 May 2011 15:39:13 +0000
- Subject: [Bug fortran/49110] New: Deferred-length character result triggers (false positive) error for pure procedures
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49110
Summary: Deferred-length character result triggers (false
positive) error for pure procedures
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jwmwalrus@gmail.com
The use of a deferred-length character variable as a function result triggers a
(false positive) error for pure procedures. For example, the following module:
module mod1
use iso_c_binding
implicit none
contains
pure function c2fstring(cbuffer) result(string)
character(:), allocatable :: string
character(KIND = C_CHAR), intent(IN) :: cbuffer(:)
integer :: i
continue
string = REPEAT(' ', SIZE(cbuffer))
do i = 1, SIZE(cbuffer)
if (cbuffer(i) == C_NULL_CHAR) exit
string(i:i) = cbuffer(i)
enddo
string = TRIM(string)
end function
end module mod1
When compiled, the error thrown is:
...:~$ gfortran -c test_gfortran_pure.f90
test_gfortran_pure.f90:4.4:
pure function c2fstring(cbuffer) result(string)
1
Error: CHARACTER(*) function 'c2fstring' at (1) cannot be pure
The module compiles just fine with ifort v12.0.4 (command line: ifort -c -stand
test_gfortran_pure.f90).
The version information is:
...:~$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.6.0-3~ppa1'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-multiarch
--with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/x86_64-linux-gnu
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 20110409 (prerelease) (Ubuntu 4.6.0-3~ppa1)
The system information (for Ubuntu 11.04) is:
...:~$ uname -srvmpio
Linux 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64
x86_64 x86_64 GNU/Linux