This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: ICE on valid
On Saturday, September 22, 2012 07:36:20 PM Janus Weil wrote:
> >> > Thanks for confirming, and for figuring out that this is actually
> >> > invalid
> >> > code. In this case my goal was just to pass a pointer to a Fortran
> >> > polymorphic variable through to the C-side of my code, and then be able
> >> > to pass that pointer back later on.
> >>
> >> if you do that, then I guess you have to convert your Fortran
> >> polymorphic pointer to a C_PTR at some point, probably via C_LOC,
> >> right? However, C_LOC should not accept polymorphic arguments in the
> >> first place. Haven't you been bitten by this?
> >
> > I haven't tried working around this yet, but my idea was to wrap the
>
> > polymorphic object in a derived type:
> My question was actually not so much targeted towards your future
> workaround, but more as to why you're not getting any errors from
> C_LOC, when converting your Fortran CLASS pointer to a C pointer
> (which is sort of the opposite of what C_F_POINTER does) ...
>
> (But probably what you're doing is just different from what I'm
> imagining you would do.)
You're right - I am seeing these errors when I try to compile the relevant
file. So, I'd have realized that this approach wouldn't work if I'd compiled
that file first!
Cheers,
Andrew.
--
* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
* Galacticus: http://sites.google.com/site/galacticusmodel