public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49993] New: arrays declared as parameter are not allocated in read-only memory
@ 2011-08-05 17:32 arnaud02 at users dot sourceforge.net
  2011-08-08 10:28 ` [Bug fortran/49993] " arnaud02 at users dot sourceforge.net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: arnaud02 at users dot sourceforge.net @ 2011-08-05 17:32 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: arnaud02@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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-04 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-05 17:32 [Bug fortran/49993] New: arrays declared as parameter are not allocated in read-only memory arnaud02 at users dot sourceforge.net
2011-08-08 10:28 ` [Bug fortran/49993] " arnaud02 at users dot sourceforge.net
2011-08-08 15:05 ` kargl at gcc dot gnu.org
2011-08-09 20:25 ` arnaud02 at users dot sourceforge.net
2011-11-04 10:35 ` arnaud02 at users dot sourceforge.net
2011-11-04 11:00 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).