Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Warning about undefined return values

Anonymous
Not applicable
5,560 Views

Hi

Since I use the oneAPI Fortran compiler ifort on Windows I get sometimes spurious warnings about undefined return values:

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

The warning does not say which function it means!

sourcefile.f90 uses a module which itselfs compiles cleanly without warnings.

The warning does not come up in every case.

Could someone explain to me why this warning is shown?

Thank you in advance

--tsbg

0 Kudos
28 Replies
FortranFan
Honored Contributor III
1,344 Views

@jimdempseyatthecove ,

As you may recall, type(c_ptr) is an intrinsic derived type declared as part of the intrinsic module, ISO_C_BINDING.  It supports certain operations only; if assignment is desired, then one has to do so to other objects or constants of said derived type e.g., c_null_ptr.

But I don't think it has any bearing on the warning noticed by OP:

module m
   use, intrinsic :: iso_c_binding, only : c_int, c_loc, c_ptr, c_null_ptr
   integer(c_int), pointer :: pa => null()
contains
   function foo() result(cp)
      type(c_ptr) :: cp
      !cp = c_null_ptr !<-- Including or excluding this line has no impact on warning issuance 
      if ( associated(pa) ) then
         cp = c_loc( pa )
      end if 
   end function 
end module 

Note no warning below:

C:\Temp>ifort /c /standard-semantics /warn:all /stand:f18 c.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1.2 Build 20201208_000000
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.


C:\Temp>

 

The warning that bothers OP is something specific to code in that 'sourcefile.f90'.  OP can subscribe to support with Intel, if not done already, and spare the readers the trouble of being blind sleuths, for Intel support can then investigate the root cause of the warning.

 Or, share the relevant code here so readers can provide more informed replies.

0 Kudos
Anonymous
Not applicable
1,319 Views

Thank you all for your insights.

I will stop bothering you with my problem until I can present a working example. I don't wan't you to be blind sleuths and I can not work any longer on this problem for now.

Thank you.

-- tsbg

0 Kudos
Thomas_F_1
Beginner
1,255 Views

We have run into this same problem over the course of the last several years, and it seems to be getting worse with the 2022 compiler edition (ifort).

was able to create a small test case that reproduces the issue, but only on macOS. With the small test case, the issue does not appear on Windows or Linux. With our full code, the problem occurs on all three platforms.

I've submitted the attached test case to Intel (paid) support, but wanted to post it here for others to test. I assert that this is a bug in the Intel compiler.

To test, compile only with `-c`. When I do this, I end up with the following warning:

$ ifort -c no_return_value.F90 
/var/folders/ld/q3szx2j10w3_vbvc273tmmtr0000gn/T/ifortsm051o.i90: warning #6178: The return value of this FUNCTION has not been defined.   [CPTR__]

 Note that in our case, the warnings are generated against temporary assembly (*.i90) files.

The challenge with a large code base is that we get multiple warnings... every time one of two particular module is used

0 Kudos
FortranFan
Honored Contributor III
1,242 Views

@Thomas_F_1 ,

A couple of considerations:

  1. Open a new thread and you can link an existing thread if you think it's relevant.
  2. Now that you've requested paid support and can hopefully expect an appropriate solution from Intel, while waiting for the same look into -Qdiag-disable (*UX), /Qdiag-disable (Windows) option as an interim workaround.
C:\temp>ifort /c /fpp /standard-semantics no_return_value.F90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

C:\Users\parekhv\AppData\Local\Temp\3030013.i90: warning #6178: The return value of this FUNCTION has not been defined.   [CPTR__]

C:\temp>ifort /c /fpp /standard-semantics /Qdiag-disable:6178 no_return_value.F90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.


C:\temp>

By the way, Intel already has other support request to correct the unnecessary warning. 

0 Kudos
Steve_Lionel
Honored Contributor III
1,244 Views

It reproduces for me on Windows:

D:\Projects>ifort -c no_return_value.F90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.1 Build 20221019_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

no_return_value.F90: warning #6178: The return value of this FUNCTION has not been defined.   [CPTR__]

Some further refinement is possible, but the use of nested modules is a key factor. Something is corrupting the compiler's symbol table.

0 Kudos
Thomas_F_1
Beginner
1,231 Views

Thanks for confirming Steve. I've tried in the past coming up with a simple example, but couldn't work out what triggered it. The latest 2022 compiler actually made the problem worse, but that helped track down when it was occurring. As you said, nested modules, along with function interfaces that return type(c_ptr), seems to be the key.

0 Kudos
JohnNichols
Valued Contributor III
1,226 Views

So we can see what they are nattering about:

 

!===============================================================================
module ZMQ_Interfaces
use, intrinsic :: iso_c_binding
implicit none

	! ZMQ Message Type
	type, bind(C) :: zmq_msg_t
		! Opaque data type
		private
		character(kind=c_char) :: dat(64)
	end type

	interface

		! zmq_msg_data - retrieve pointer to message content
		! void *zmq_msg_data (zmq_msg_t *msg);
		function zmq_msg_data(msg) result(ptr) bind(C,name="zmq_msg_data")
			use, intrinsic :: iso_c_binding
			import zmq_msg_t
			type(zmq_msg_t) :: msg
			type(c_ptr) :: ptr
		end function

	end interface

end module ZMQ_Interfaces
!===============================================================================

!===============================================================================
module FZMQ
use ZMQ_Interfaces
use, intrinsic :: iso_c_binding

	!---------------------------------------
	!> FZMQ Message Object. (incomplete)
	type, public :: FZMQ_Message
		private
		type(zmq_msg_t) :: self
	contains
 		procedure :: Data => MsgData
	end type

contains

!---------------------------------------
function MsgData(my) result(cptr__)
use, intrinsic :: iso_c_binding
implicit none
	class(FZMQ_Message) :: my
	type(c_ptr) :: cptr__

	cptr__ = zmq_msg_data(my%self)

end function

end module FZMQ
!===============================================================================

!===============================================================================
module SAS_PortAuthority
use FZMQ
implicit none
private

	type :: test
		type(FZMQ_Message) :: msg
	contains
		procedure :: Hello
	end type

contains

subroutine Hello(my)
implicit none

	class(test) :: my

	print *, "Hello, World!"

end subroutine

end module SAS_PortAuthority
!===============================================================================
0 Kudos
Barbara_P_Intel
Employee
1,216 Views

@Thomas_F_1 , I see that you filed a support ticket on this. Thank you!

 

0 Kudos
Reply