Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:28:17+00:00 2026-06-07T06:28:17+00:00

I am trying to write a generic type-bound procedure that takes different callback functions

  • 0

I am trying to write a generic type-bound procedure that takes different callback functions as parameters. When compiling following code (with ifort 12.1.3) I get the warning below:

module test

type :: a_type
  contains
  procedure :: t_s => at_s
  procedure :: t_d => at_d
  generic :: t => t_s,t_d
end type a_type

abstract interface
  integer function cb_s(arg)
  real(4) :: arg
  end function cb_s

  integer function cb_d(arg)
  real(8) :: arg
  end function cb_d
end interface

contains

subroutine at_s(this,cb)
  class(a_type) :: this
  procedure(cb_s) :: cb 
end subroutine

subroutine at_d(this,cb)
  class(a_type) :: this
  procedure(cb_d) :: cb 
end subroutine

end module test

The warning:

compileme.f(27): warning #8449: The type/rank/keyword signature for this specific
procedure matches another specific procedure that shares the same generic
binding name.   [AT_D]

It seems like the compiler is not differentiating between different function interfaces when used as procedure arguments…

My question is: Why aren’t those types checked and what is the correct, clean way to write generic type-bound procedures with procedures or procedure pointers as arguments?

Possible solution

As Vladimir F pointed out, only the callback function’s return arguments are type checked. In my case it is OK to then just slightly change the functions’ interfaces:

abstract interface
  real(4) function cb_s(arg)
  real(4) :: arg
  end function cb_s

  real(8) function cb_d(arg)
  real(8) :: arg
  end function cb_d
end interface
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:28:20+00:00Added an answer on June 7, 2026 at 6:28 am

    The compiler is right, because Fortran 2008’s 12.4.3.4.5 Restrictions on generic declarations has

    Two dummy arguments are distinguishable if
    – one is a procedure and the other is a data object,
    – they are both data objects or known to be functions, and neither is TKR compatible with the other,
    – one has the ALLOCATABLE attribute and the other has the POINTER attribute, or
    – one is a function with nonzero rank and the other is not known to be a function.

    It means that both your functions are integer functions so they are not distinguishable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a generic interpolate method that works on any type that
I am trying to write a generic method that would bind any asp.net UI
I'm trying to write a generic function that works with JSON arrays containing arbitrary
I am trying to write a function that will convert a generic list to
I am trying to write a generic Heap Sort algorithm. I get the following
I'm trying to write a generic method to serialize an object that inherits from
I'm trying to write a class that has a generic member variable but is
Im trying to write a generic base class that will allow sub classes to
I am trying to write a generic iterator that coputes the Fibonacci sequence: def
I am trying to write a generic method that will convert a DataTable to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.