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

String pointers with DLLEXPORT

Dalziel__Stuart
Beginner
480 Views
I am using XE 2011.1.127, so it may be that this problem has been fixed...

There appears to be a compiler error resulting from the following code segment:

module Junk
contains
function Test(pS,S1,S2)
!DEC$ ATTRIBUTES DLLEXPORT, REFERENCE, alias:"Test" :: Test
logical Test
character (*), pointer :: pS
character (*), intent(in), target :: S1
character (*), intent(in), target :: S2
integer (4), automatic :: iPS,iL1, iL2
iPS = len(pS)
iL1 = len(S1)
iL2 = len(S2)
pS => S1
Test = .true.
return
end function
end module


program StringPointer
use Junk
character (32), pointer :: pS
logical bret

bret = Test(pS,'123','ABCDEFG')

end program StringPointer

Inspection of the disassembled version demonstrates that with the DLLEXPORT directive then the code generated to call Test(..) has five parameters put on the stack: the addresses of the pointer pS and the two static strings, plus the length of the two static strings. No length associated with the string pointer pS is put on the stack. In contrast, the disassembly of the function shows that it is expecting six parameters, i.e., incluiding the length of pS. The corresponding values of iPS, iL1 and iL2 are 3, 7 and zero.

Removing the DLLEXPORT causes the compiler to include a length for the pointer pS in both places.

I can (and have) worked around this problem, but it took a while to track down the cause.

Stuart

0 Kudos
6 Replies
IanH
Honored Contributor II
480 Views
Perhaps there are other problems, but note you are associating a non-deferred length pointer of length 32 with a target that has length 3. That's not legal.


0 Kudos
Dalziel__Stuart
Beginner
480 Views
Quoting IanH
Perhaps there are other problems, but note you are associating a non-deferred length pointer of length 32 with a target that has length 3. That's not legal.


I agree that there are elements of my example that are not sensible, but it was just meant to illustrate the problem. I electeddifferent sizes here to help highlight what was happening to the size info butforgot to remove the pointer association from an earlier test.The software itself (~16MB of source total)is consistent aboutsizes of the strings, and indeed the problematic routine compiles perfectly OK under CVF.

Stuart
0 Kudos
Steven_L_Intel1
Employee
480 Views
Please try a newer compiler. This problem looks like one we fixed a while ago.
0 Kudos
IanH
Honored Contributor II
480 Views
FWIW I still observe the apparent argument mismatch with 12.1.4.
0 Kudos
Steven_L_Intel1
Employee
480 Views
Ok, this is a different problem than before. I can reproduce it and will escalate to development. The DLLEXPORT doesn't seem to be relevant here. ATTRIBUTES REFERENCE does need to be specified to see the problem. I'm not sure why you have that, however. What did you expect it to do?

Issue ID is DPD200233584
0 Kudos
Steven_L_Intel1
Employee
480 Views
This has been fixed for an update later this year (October or thereabouts).
0 Kudos
Reply