This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49993] New: arrays declared as parameter are not allocated in read-only memory
- From: "arnaud02 at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 5 Aug 2011 17:31:51 +0000
- Subject: [Bug fortran/49993] New: arrays declared as parameter are not allocated in read-only memory
- Auto-submitted: auto-generated
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.