The return value of this FUNCTION has not been defined

I get the following warning when compiling this example code using the intel ifx fortran compiler. It says that the return value of a function has not been defined when, from what I can see, it has. The code compiles fine though and runs as expected.

I have similar versions of this (more complex ones) where this warning does not appear (and other, just as complex ones that do have this warning), but I have not been able to produce a small working example yet. I will post an example of it not producing the warning if I get one working.

Some help on why this warning appears would be greatly appreciated.

Warning message:

main.f90: warning #6178: The return value of this FUNCTION has not been defined. [OUTPUT]

IFX compiler version:

ifx (IFX) 2023.2.0 20230721

Here is the code:

module example_module
  implicit none

  private
  public :: base_type

  type :: base_type
     real :: value
  end type base_type

  interface base_type
     module function setup() result(output)
       type(base_type) :: output
     end function setup
  end interface base_type

contains

 module function setup() result(output)
    implicit none
    type(base_type) :: output

    output%value = 12.E0
  end function setup

end module example_module

program main
  use example_module
  implicit none
  
  write(*,*) base_type()
  
end program main

I have built the program with gfortran and that does not complain. But Intel oneAPI Fortran 2023 and 2024 both complain. Renaming the function to base_type_x made no difference - I thought it might perhaps be confused by the name being the same as that of the derived type.

You can report this to Intel.

1 Like

Thanks for checking, @Arjen. :slight_smile:

Yeah, I’ve found it has no issue when compiling this using gfortran either, and they all still produce a code that executes successfully.

I’ll report this to intel then.

This is a false warning that I have seen displayed for years when the function is a derived type constructor. I never figured out the underlying reason, but I also never took it seriously, as it is only a (seemingly false) warning.

I’m not familiar with the syntax used above but the following, which is similar, doesn’t produce the warning message using IFORT 2021.7.0 or IFX 2022.2.0

module example_module
  implicit none

  private
  public :: base_type

  type :: base_type
     real :: value
  end type base_type

  interface base_type
     module procedure setup
  end interface base_type

contains

 function setup() result(output)
    type(base_type) :: output

    output%value = 12.E0
 end function setup

end module example_module

program main
  use example_module
  implicit none
  
  write(*,*) base_type()
  
end program main

@nedanator, did you get this reported to Intel? I can write up a bug report directly from here if not.

Sorry @greenrongreen, I never noticed this response (didn’t seem to get an email about it and life stuff started getting in the way). I don’t think I did log this with Intel. I looked through my emails, but don’t think I did log this with Intel.