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

character function return length specified by dummy arg

David_Mccabe
Beginner
638 Views

The following code snippet seems to be working fine in debug and causing access violations in release:

[fortran]

!------------------------------------------

! c_string to character string conversion.

function f_string(cStr,fStr_size) result (fStr)

type(c_string) :: cStr

integer :: fStr_size

character(len=fStr_size) :: fStr

!call c_string_to_character_string(fStr,cStr)

end function f_string

[/fortran]

 Perhaps it is illegal to have the return length specified by dummy arg?

0 Kudos
4 Replies
David_Mccabe
Beginner
638 Views
The code snippet above work fine, the problem must be introduced elsewhere. This forms part of a test project in where I am trying out type bound procedures for the first time. I have uploaded the project files...
0 Kudos
Steven_L_Intel1
Employee
638 Views
David, you have been very naughty. You used BIND(C) to call a STDCALL routine, papering over the error by including the @n name decoration in the external names in the BIND clause. This causes stack corruption. In Intel Fortran, BIND(C) cannot be used to call STDCALL routines - only the default C convention is allowed.
0 Kudos
David_Mccabe
Beginner
638 Views
Ah! I was unaware this was the case. The code now works fine. Thank you
0 Kudos
Steven_L_Intel1
Employee
638 Views
In general, any time you find yourself adding the @n suffix to an external name string to fix up a linking error, that should be a red flag that you're probably doing something wrong.
0 Kudos
Reply