http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49993

           Summary: arrays declared as parameter are not allocated in
                    read-only memory
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: arnau...@users.sourceforge.net


Consider the following illegal program which contains an attempt to modify a
scalar variable declared as parameter:
      subroutine a1(ia)
      integer :: ia
      ia=1
      end subroutine
      subroutine a2()
      integer, parameter :: ia = 2
      call a1(ia)
      end subroutine
      program m
      call a2()
      end program
As "ia" is allocated in the "rodata" section, this leads sensibly to a
"segmentation fault".

Consider now a similar program that with an array instead of a scalar:
      subroutine a1(ia)
      integer :: ia
      ia=1
      end subroutine
      subroutine a2()
      integer, parameter :: ia(1) = (/ 2 /)
      call a1(ia(1))
      end subroutine
      program m
      call a2()
      end program
This time, now "segmentation fault" is generated because array "ia" is not
allocated in the "rodata" section. 
Could gfortran be modified to allocate arrays declared in parameter in the
rodata section? This would help detecting bugs and may even provide a slight
performance and code size advantage.

Reply via email to