This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/36761] New: Unallocated array "referenced" silently
- From: "terry at chem dot gu dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2008 07:02:52 -0000
- Subject: [Bug fortran/36761] New: Unallocated array "referenced" silently
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I'm really not sure whether to consider this a bug or a "feature". It
certainly *seems* to me that it's non-conforming code that compiles and runs
happily.
[tjf@rscpc28 BadStuff]$ cat alloc.f90
module aa
implicit none
real(kind=8),dimension(:,:),allocatable::Md
end module aa
program fred
use aa
implicit none
write(*,*)allocated(Md)
write(*,*)Md(1,:)
end
[tjf@rscpc28 BadStuff]$ gfortran -Wall -O0 -W -Wtabs -g -fbounds-check
-fbacktrace -pedantic -std=f95 -o alloc alloc.f90
[tjf@rscpc28 BadStuff]$ ./alloc
F
[tjf@rscpc28 BadStuff]$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3-20080626/configure --disable-multilib
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.3.2 20080626 (prerelease) (GCC)
If Md is in not in a module running ./alloc segfaults. Using a definite
element gets picked up as a bounds violation. Writing Md(1,1:0) gives the same
silent output as above.
Should one really consider an unallocated array to be size 0?
--
Summary: Unallocated array "referenced" silently
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terry at chem dot gu dot se
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36761