character function return length specified by dummy arg

character function return length specified by dummy arg

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

! 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

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

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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


Downloadapplication/zip apache-interfaces.zip1.63 MB

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.

Retired 12/31/2016

Ah! I was unaware this was the case. The code now works fine.

Thank you

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.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today