This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49993] arrays declared as parameter are not allocated in read-only memory
- From: "kargl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 8 Aug 2011 15:05:27 +0000
- Subject: [Bug fortran/49993] arrays declared as parameter are not allocated in read-only memory
- Auto-submitted: auto-generated
- References: <bug-49993-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49993
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org 2011-08-08 15:05:10 UTC ---
(In reply to comment #1)
> The equivalent "C" program results in the expected "segmentation fault".
>
> void a1(int *ia) {
> *ia = 1;
> }
> void a2(void) {
> static const int ia[] = { 2 };
> a1(ia);
> }
> int main(void) {
> a2();
> return 0;
> }
The programs aren't equivalent. You need to change a2 to
void a2(void) {
static int ia[] = { 2 };
a1(ia);
}
then the programs are equivalent.