Recurring theme

  • Follow


This issue happens in so many guises...

C:\gfortran\clf\opengl\f03gl\random_sphere>type bug1.f90
module glu_primitive
   use ISO_C_BINDING, only: GLUquadric=>C_PTR
   implicit none
   private
   public GLUquadric
end module glu_primitive

module glu
   use glu_primitive, only: GLUquadric
   implicit none
   private

   public GLUquadric,gluNewQuadric
   interface
      function gluNewQuadric() &
         bind(C,name='gluNewQuadric')
         import
         implicit none
!GCC$ ATTRIBUTES STDCALL :: gluNewQuadric
         type(GLUquadric) gluNewQuadric
      end function gluNewQuadric
   end interface
end module glu

program test
   use ISO_C_BINDING,only: C_PTR
   use glu,only: gluQuadric, gluNewQuadric
   implicit none
   type T
      type(C_PTR) c
   end type T
   type(T) i

   i%c = gluNewQuadric()
end program test

C:\gfortran\clf\opengl\f03gl\random_sphere>gfortran bug1.f90 -obug1
bug1.f90:34.9:

   i%c = gluNewQuadric()
         1
Error: Can't convert TYPE(gluquadric) to TYPE(c_ptr) at (1)

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


0
Reply not_valid (1681) 2/17/2011 8:02:00 AM

On Feb 17, 12:02=A0am, "James Van Buskirk" <not_va...@comcast.net>
wrote:
> This issue happens in so many guises...
>
> C:\gfortran\clf\opengl\f03gl\random_sphere>type bug1.f90
> module glu_primitive
> =A0 =A0use ISO_C_BINDING, only: GLUquadric=3D>C_PTR
> =A0 =A0implicit none
> =A0 =A0private
> =A0 =A0public GLUquadric
> end module glu_primitive
>
> module glu
> =A0 =A0use glu_primitive, only: GLUquadric
> =A0 =A0implicit none
> =A0 =A0private
>
> =A0 =A0public GLUquadric,gluNewQuadric
> =A0 =A0interface
> =A0 =A0 =A0 function gluNewQuadric() &
> =A0 =A0 =A0 =A0 =A0bind(C,name=3D'gluNewQuadric')
> =A0 =A0 =A0 =A0 =A0import
> =A0 =A0 =A0 =A0 =A0implicit none
> !GCC$ ATTRIBUTES STDCALL :: gluNewQuadric
> =A0 =A0 =A0 =A0 =A0type(GLUquadric) gluNewQuadric
> =A0 =A0 =A0 end function gluNewQuadric
> =A0 =A0end interface
> end module glu
>
> program test
> =A0 =A0use ISO_C_BINDING,only: C_PTR
> =A0 =A0use glu,only: gluQuadric, gluNewQuadric
> =A0 =A0implicit none
> =A0 =A0type T
> =A0 =A0 =A0 type(C_PTR) c
> =A0 =A0end type T
> =A0 =A0type(T) i
>
> =A0 =A0i%c =3D gluNewQuadric()
> end program test
>
> C:\gfortran\clf\opengl\f03gl\random_sphere>gfortran bug1.f90 -obug1
> bug1.f90:34.9:
>
> =A0 =A0i%c =3D gluNewQuadric()
> =A0 =A0 =A0 =A0 =A01
> Error: Can't convert TYPE(gluquadric) to TYPE(c_ptr) at (1)
>
troutmask:sgk[214] diff -u a.f90 b.f90
--- a.f90       2011-02-17 07:50:36.000000000 -0800
+++ b.f90       2011-02-17 07:53:27.000000000 -0800
@@ -27,7 +27,7 @@
    use glu,only: gluQuadric, gluNewQuadric
    implicit none
    type T
-      type(C_PTR) c
+      type(GLUquadric) c
    end type T
    type(T) i

--
steve

0
Reply kargls (354) 2/17/2011 3:55:10 PM


steve <kargls@comcast.net> wrote:

> On Feb 17, 12:02 am, "James Van Buskirk" <not_va...@comcast.net>
> wrote:
....
> >    use ISO_C_BINDING, only: GLUquadric=>C_PTR

>     type T
> -      type(C_PTR) c
> +      type(GLUquadric) c
>     end type T
>     type(T) i

Note the above-quoted rename clause in the USE statement. That ought to
make the two forms equivalent. That is doesn't would be a bug.

While I agree that it is confusing, enough so that my intial reaction
was much like Steve's, it is supposed to work.

-- 
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain
0
Reply nospam47 (9742) 2/17/2011 5:38:01 PM

On Feb 17, 9:38=A0am, nos...@see.signature (Richard Maine) wrote:
> steve <kar...@comcast.net> wrote:
> > On Feb 17, 12:02 am, "James Van Buskirk" <not_va...@comcast.net>
> > wrote:
> ...
> > > =A0 =A0use ISO_C_BINDING, only: GLUquadric=3D>C_PTR
> > =A0 =A0 type T
> > - =A0 =A0 =A0type(C_PTR) c
> > + =A0 =A0 =A0type(GLUquadric) c
> > =A0 =A0 end type T
> > =A0 =A0 type(T) i
>
> Note the above-quoted rename clause in the USE statement. That ought to
> make the two forms equivalent. That is doesn't would be a bug.
>
> While I agree that it is confusing, enough so that my intial reaction
> was much like Steve's, it is supposed to work.
>

Of course, it should work.  The diff was a little tongue-in-cheek
humor, which actually allows the code to compile.  If James is
going to post with a subject line of "Recurring theme", then he
already knows there is a bug in gfortran and the bug hasn't
been fixed.  Sending yet-another-post to clf about a renaming
issue with C_PTR in gfortran without directly contacting the
developers either through the fortran@gcc... mailinglist or
bugzilla is a pointless exercise.

--
steve

0
Reply kargls (354) 2/17/2011 6:23:17 PM

3 Replies
71 Views

(page loaded in 0.065 seconds)

Similiar Articles:




7/15/2012 10:00:06 AM


Reply: