# Ifort does not recognize an overridden procedure in an extended class

**URL:** <https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790>\
**Category:** Help\
**Created:** [May 11, 2023, 12:29pm UTC](https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790 "2023-05-11T12:29:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [May 11, 2023, 12:29pm UTC](https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790/1 "2023-05-11T12:29:06Z")

</div>

Apologies again for the second ifort-related topic today (again trying to build `fpm` with the Intel compiler). I have an issue with ifort 2021.7 and ifx 2022.1 reproduced by this example program. I have an extended class, where one of the procedures in a generic interface is overridden. Ifort does not seem to recognize that, and the base procedure is always called:

```auto
module b
  type :: base
      contains
      procedure, private :: ba
      procedure, private :: bb
      generic :: ab => ba,bb
   end type

   contains

   subroutine ba(self,one)
      class(base), intent(inout) :: self
      integer, intent(in) :: one
      print *, 'BA'
   end subroutine ba
   subroutine bb(self,many)
      class(base), intent(inout) :: self
      integer, intent(in) :: many(:)
      print *, 'BB'
   end subroutine bb

end module b

module e
  use b

   type, extends(base) :: extended
      contains
      procedure, private :: bb => bb_extended
   end type  

   contains

   subroutine bb_extended(self,many)
      class(extended), intent(inout) :: self
      integer, intent(in) :: many(:)
      print *, 'BB_EXT'
   end subroutine bb_extended    
end module e   

program test
  use e
  type(extended) :: my
  call my%ab([1,2,3,4,5])
end program test  

```

produces output:

```auto
 BB

```

instead of `BB_EXT` . Curiously, if both base and extended class are into the same module, the correct output is produced ([see here](https://godbolt.org/z/eh1PTTKdK)).

Can I ask any of the Intel Fortran gurus directions? Should I file this issue to the Intel support? Thank you in advance. The issue can be [tested on godbolt](https://godbolt.org/z/bEaE3fre3).

---

<div class="post-metadata">

**Author:** ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)\
**Post date:** [May 11, 2023, 2:01pm UTC](https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790/2 "2023-05-11T14:01:54Z")

</div>

> If a specific type-bound procedure specified in a type definition has the same binding name as an accessible type-bound procedure from the parent type then the binding specified in the type definition overrides the one from the parent type.
> 
> - Fortran Draft Standard 2023, Sec. 7.5.7.3 Type-bound procedure overriding

The key word there is **accessible**. The private type-bound procedure is not accessible in the extended type defined in a separate module, and therefore it cannot be overriden.

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [May 11, 2023, 3:15pm UTC](https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790/3 "2023-05-11T15:15:23Z")

</div>

Great spotting that! Thank you @everythingfunctional, much appreciated.

As a side comment, I also routinely use setting functions `private` when they’re part of a generic interface, because I only want the generic interface to be accessible all the way up. The standard you’re showing tells me that this coding strategy is not a good practice in Fortran though.

---

<div class="post-metadata">

**Author:** ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)\
**Post date:** [May 11, 2023, 10:10pm UTC](https://fortran-lang.discourse.group/t/ifort-does-not-recognize-an-overridden-procedure-in-an-extended-class/5790/4 "2023-05-11T22:10:46Z")

</div>

I think it is good practice, with the limitation that specific procedures can’t be overridden.
