Bug 47360 - GENERIC with proc-pointer components as specific functions
Summary: GENERIC with proc-pointer components as specific functions
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-01-19 15:57 UTC by Tobias Burnus
Modified: 2011-01-19 16:04 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-01-19 15:57:24 UTC
Related to PR 47352. 

Both where reported by James in the same thread:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/bbaf59ffd7c372e9


The program in question fails with

         GENERIC :: gen => f1, g1
                          1
  Error: Undefined specific binding 'g1' as target of GENERIC 'gen' at (1)


At a glance, the program looks as if it could be valid - though also Crayftn does not like it (ifort 11 and NAG f95 5.1 do not support GENERIC, yet).


module mytypes
   implicit none
   abstract interface
      function f(x)
         real f, x
      end function f
      function g(x)
         integer g, x
      end function g
   end interface
   type T
      procedure(f),pointer,NOPASS :: f1
      procedure(g),pointer,NOPASS :: g1
      contains
         GENERIC :: gen => f1, g1
   end type T
end module mytypes

module funcs
   implicit none
   contains
      function f(x)
         real f, x
         f = 3*x
      end function f
      function g(x)
         integer g, x
         g = 3*x
      end function g
end module funcs

program test
   use mytypes
   use funcs, f2=>f, g2=>g
   implicit none
   type(T) tau

   tau%f1 => f2
   tau%g1 => g2
   write(*,*) tau%gen(1)
   write(*,*) tau%gen(1.0)
end program test
Comment 1 Tobias Burnus 2011-01-19 16:04:43 UTC
"R450 type-bound-generic-stmt
      is GENERIC [ , access-spec ] :: generic-spec => binding-name-list"

"C467 (R450) Each binding-name in binding-name-list shall be the name of
             a specific binding of the type."

"1.3.13 binding name: name given to a specific or generic type-bound procedure in the type definition (4.5.5)"

And in 4.5.5:
"R447 type-bound-proc-binding is type-bound-procedure-stmt
                              or type-bound-generic-stmt
                              or final-procedure-stmt"

Hence, the example seems to be invalid as "f1" and "g1" are not type-bound procedures. -> Close PR.