https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71412

--- Comment #4 from relliott at umn dot edu ---
> Ahem, give val the SAVE attribute.
>
>  integer(c_int), pointer, save :: val

Hi,  Thanks for your help.  Unfortunately, I don't think using save will serve 
my purpose in this case.  Although, now I see that the skeleton code does not 
illustrate this aspect of my requirements.  The myalloc() function is supposed 
to be able to allocate multiple independent values.

I've updated the code to demonstrate this requirement.  Attached.

The typical output is now:

$ make
gfortran -m32 -O3 -g -Wall -pedantic  -c skeleton-f.F90
gcc -m32 -O3 -g -Wall -ansi -pedantic  -c skeleton-c.c
gfortran -m32 -O3 -g -Wall skeleton*.o  -o skeleton

$ ./skeleton
  -- in storePtr: pointer address --> 0x78625940 <-- value --> 805306368 <--
index --> 0
  -- just a print statement --> nothing <-- index -->           0
  -- in getPtr:   pointer address --> 0x78625940 <-- value --> 805306368 <--
index --> 0
  -- in storePtr: pointer address --> 0x78625950 <-- value --> 805306368 <--
index --> 1
  -- just a print statement --> nothing <-- index -->           1
  -- in getPtr:   pointer address --> 0x78625950 <-- value --> 805306368 <--
index --> 1
  -- value of 'val0' variable -->    805306368
  -- value of 'val1' variable -->    805306368

$ make clean
rm -f skeleton skeleton*.o *.mod

$ make DEFS=-DOK
gfortran -m32 -O3 -g -Wall -pedantic -DOK -c skeleton-f.F90
gcc -m32 -O3 -g -Wall -ansi -pedantic -DOK -c skeleton-c.c
gfortran -m32 -O3 -g -Wall skeleton*.o  -o skeleton

$ ./skeleton
  -- in storePtr: pointer address --> 0x78e41c80 <-- value --> -268435456 <--
index --> 0
  -- value of 'val' variable -->           21 <-- index -->            0
  -- in getPtr:   pointer address --> 0x78e41c80 <-- value --> 21 <-- index -->
0
  -- in storePtr: pointer address --> 0x78e41c90 <-- value --> -268435456 <--
index --> 1
  -- value of 'val' variable -->           12 <-- index -->            1
  -- in getPtr:   pointer address --> 0x78e41c90 <-- value --> 12 <-- index -->
1
  -- value of 'val0' variable -->           21
  -- value of 'val1' variable -->           12



Suggestions would be much appreciated.

Thanks,

Ryan

Reply via email to