This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/71412] iso_c_bindings and optimization interaction bug
- From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 04 Jun 2016 16:54:36 +0000
- Subject: [Bug fortran/71412] iso_c_bindings and optimization interaction bug
- Auto-submitted: auto-generated
- References: <bug-71412-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71412
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sat, Jun 04, 2016 at 04:36:24PM +0000, relliott at umn dot edu wrote:
> 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.
Have you considered the SAVE attribute?
integer(c_int), pointer,save :: val
laptop-kargl:kargl[246] gmake
gfc -O3 -g -Wall -pedantic -c skeleton-f.F90
~/work/bin/gcc -O3 -g -Wall -ansi -pedantic -c skeleton-c.c
gfc -O3 -g -Wall skeleton*.o -o skeleton
laptop-kargl:kargl[247] ./skeleton
-- in storePtr: pointer address --> 0x28621018 <-- value --> 0 <-- index --> 0
-- just a print statement --> nothing <-- index --> 0
-- in getPtr: pointer address --> 0x28621018 <-- value --> 21 <-- index -->
0
-- in storePtr: pointer address --> 0x28621020 <-- value --> 0 <-- index --> 1
-- just a print statement --> nothing <-- index --> 1
-- in getPtr: pointer address --> 0x28621020 <-- value --> 12 <-- index -->
1
-- value of 'val0' variable --> 21
-- value of 'val1' variable --> 12
PS: You probably do not want to use -pedantic with gfortran.
PPS: bugzilla is not an appropriate forum to learn Fortran. Try
comp.lang.fortran.