Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Internal compiler error when wrapping intrinsics with "use" renaming

Sean_S_2
Beginner
584 Views

There is a weird error if you wrap an intrinsic function, then rename the wrapper in a use statement to have the same name as the original intrinsic. This is usually something that you would only do if you wanted to choose between your own implementation of a function and the compiler's. See here:

module wrap_gamma

implicit none

contains

real function wrapper(x)
  real, intent(in) :: x
  wrapper = gamma(x)
end function wrapper

end module wrap_gamma

program test_intrinsic_name_reuse

use wrap_gamma, only: gamma => wrapper

implicit none

print *, gamma(2._r8)

end program test_intrinsic_name_reuse

I found that this only happens if you actually use the intrinsic in the wrapper (e.g. no error if you remove the "wrapper = gamma(x)" line), and the issue also goes away if you use a generic function to create another alias (e.g. creating a "wrapper2" generic function and then aliasing gamma to that in the main program above). That second case is the workaround that I've been using.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
584 Views

Thanks - I have escalated this as issue DPD200361667.

0 Kudos
Sean_S_2
Beginner
584 Views

I just noticed that I made a copy/paste error in the OP; the argument to "gamma" was supposed to be "2.0". However, this is irrelevant in that you get the same internal compiler error either way.

0 Kudos
Steven_L_Intel1
Employee
584 Views

This is fixed for a release later this year.

0 Kudos
Reply