public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48095] New: [OOP] Invalid assignment to procedure pointer component not rejected
@ 2011-03-12 17:32 janus at gcc dot gnu.org
  2011-03-12 17:46 ` [Bug fortran/48095] " janus at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-03-12 17:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48095

           Summary: [OOP] Invalid assignment to procedure pointer
                    component not rejected
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: janus@gcc.gnu.org


Reported by Arjen Markus at
http://gcc.gnu.org/ml/fortran/2011-03/msg00057.html:

The following program (slightly modified from the original) does not produce
the expected result:


module proc_pointers

  implicit none

  type :: rectangle
    real :: width, height
    procedure(get_area), pointer, pass(this) :: get_special_area => get_my_area
  end type rectangle

  abstract interface
    real function get_area( this )
      import                       :: rectangle
      class(rectangle), intent(in) :: this
    end function get_area
  end interface

contains

  real function get_my_area( this )
    type(rectangle), intent(in) :: this
    write(*,*) 'This: ', this%width, this%height
    get_my_area = 3.0 * this%width * this%height
  end function get_my_area

end module proc_pointers


program test_objects

   use proc_pointers
   implicit none

   type(rectangle) :: rect
   real            :: area

   rect  = rectangle (1.0,2.0)
   write(*,*) 'Rect: ', rect%width, rect%height
   area = rect%get_special_area()
   write(*,*) 'Special area:', area

end program test_objects


I think it is invalid, because the PPC 'get_special_area' is declared to expect
a CLASS argument, but then the procedure it points to has a TYPE argument.

One should check the standard on this.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-09-07 22:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-12 17:32 [Bug fortran/48095] New: [OOP] Invalid assignment to procedure pointer component not rejected janus at gcc dot gnu.org
2011-03-12 17:46 ` [Bug fortran/48095] " janus at gcc dot gnu.org
2011-03-27  9:01 ` janus at gcc dot gnu.org
2011-03-28 22:17 ` janus at gcc dot gnu.org
2011-03-29 10:10 ` janus at gcc dot gnu.org
2011-03-29 10:19 ` burnus at gcc dot gnu.org
2011-03-29 10:24 ` burnus at gcc dot gnu.org
2011-09-05 12:46 ` janus at gcc dot gnu.org
2011-09-05 13:15 ` janus at gcc dot gnu.org
2011-09-07 22:24 ` janus at gcc dot gnu.org
2011-09-08  2:13 ` janus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).