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.


[EMAIL PROTECTED] 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
[EMAIL PROTECTED] BadStuff]$ gfortran -Wall -O0 -W -Wtabs -g -fbounds-check
-fbacktrace -pedantic -std=f95 -o alloc alloc.f90
[EMAIL PROTECTED] BadStuff]$ ./alloc
 F

[EMAIL PROTECTED] 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

Reply via email to