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.
29282 Discussions

Linking error for constant used in specification expression

IanH
Honored Contributor III
530 Views
This little program, which I think is "legal":

[fortran]MODULE Fruits
  IMPLICIT NONE    
  PRIVATE            ! #A
  PUBLIC :: Get      ! #A 
  CHARACTER(*), PARAMETER :: names(3) = [  &
      'Apple  ',  &
      'Orange ',  &
      'Mango  ' ];              
CONTAINS
  FUNCTION Get(i) RESULT(s)    
    INTEGER, INTENT(IN) :: i
    CHARACTER(LEN_TRIM(names(i))) :: s    
    !****    
    s = names(i)    
  END FUNCTION Get
END MODULE Fruits

PROGRAM WheresThatbLinkingConstantGone
  USE Fruits  
  IMPLICIT NONE
  !****
  WRITE (*, "('Eat the tasty ',A)") Get(1)
END PROGRAM WheresThatbLinkingConstantGone
[/fortran]
when compiled and linked using 11.1.065 with /warn:all /check:all /stand:f03 results in an unresolved external symbol error for _FRUITS_GET_mp_NAMES in _MAIN__.

Has that symbol been "mangled" correctly? I see _FRUITS_mp_NAMES in the symbol table which looks more like what I'd expect.

If I comment out the lines marked "#A" the link suceeds.

Thanks for any advice,

IanH

0 Kudos
3 Replies
mecej4
Honored Contributor III
530 Views
The error message suggests that when the compiler sees the reference to "names(i)" on Line-12 it has forgotten the definition of "names" as a parameter array on Line-5, possibly as a result of a misapplication of host-association rules, specifically the attribute PRIVATE.

If "names" were undeclared, the reference to it on Line-12 would be compiled as a call to an external function "names" with argument "i", as a result of implicit typing rules coming into play.
0 Kudos
Steven_L_Intel1
Employee
530 Views
Interesting. It's not that the compiler "forgot" but it is definitely confused. I'll report it. Thanks. Issue ID is DPD200155685.
0 Kudos
Steven_L_Intel1
Employee
530 Views
Fixed in version 12.
0 Kudos
Reply