<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic BIND C or !DEC$ ATTRIBUTES C in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852632#M66535</link>
    <description>Yes, I can reproduce it using 11.1.048. We don't do "patches" - we fix issues by releasing an update that installs a new compiler. I verified that indeed version 048 does not pop the stack after the call and version 060 does. However, I am unable to identify which problem report in our database led to this fix, not that knowing this would help you.</description>
    <pubDate>Wed, 07 Apr 2010 17:09:23 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2010-04-07T17:09:23Z</dc:date>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852623#M66526</link>
      <description>&lt;P&gt;I have been using BIND(C,NAME='SubName') within an interface block to call functions declared in a C++ library. The Fortran project calling convention is set to CVF (Properties &amp;gt; Fortran &amp;gt; External Procedures) and the equivalent C++ project setting is cdecl. &lt;/P&gt;&lt;P&gt;Does the use of BIND(C,...) force the use of cdecl? Or is it still necessary to explicitly specify the calling convention with the use of !DEC$ ATTRIBUTES C in the interface where the project settings do not match as above? I understand this is the case for stdcall, but was under the impression BIND(C,...) assumed cdecl.  My program exhibits behaviour typical of stack corruption when I use BIND(C,...) with the settings mentioned above, but behaves correctly when I omit the BIND construct and include !DEC$ ATTRIBUTES C, DECORATE, ALIAS: 'SubName' ::SubName in the interface block.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2010 16:00:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852623#M66526</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-06T16:00:23Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852624#M66527</link>
      <description>BIND(C) forces the CDECL calling convention but does not have the side-effect of changing passing mechanism to "by value", which ATTRIBUTES C does. Use the VALUE attribute (Fiortran 2003 attribute, not !DEC$ ATTRIBUTES) if you want pass-by-value.</description>
      <pubDate>Tue, 06 Apr 2010 16:30:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852624#M66527</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-04-06T16:30:13Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852625#M66528</link>
      <description>&lt;P&gt;Thanks. My program is crashing due to access violation whenever I call a C++ subroutine with arguments from Fortran (the crash behaviour is not reproducible if functions with no arguments are called). I have a few static variables declared in the C++ module although am not if this is likely to be the cause.&lt;/P&gt;&lt;P&gt;Fortran interface:&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;[fortran]INTERFACE&lt;BR /&gt;SUBROUTINE MySub (retVal, var1, var1, var3) BIND(C,NAME='MySub')
	INTEGER retVal
	INTEGER var1 [VALUE]
	INTEGER var2 [VALUE]
	INTEGER var3 [VALUE]
END&lt;BR /&gt;&lt;BR /&gt;!other subroutines...&lt;BR /&gt;&lt;BR /&gt;END INTERFACE&lt;BR /&gt;&lt;BR /&gt;(var2 is a dummy argument of type INTEGER)
INTEGER :: retVal = 0
INTEGER :: var1 = 0&lt;BR /&gt;INTEGER :: var3 = 1

CALL MySub (retVal, var1, var2, var3)
[/fortran]&lt;/PRE&gt; &lt;/P&gt;&lt;P&gt;C++ callee:&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;[cpp]//Static vars
vector&lt;MYCLS&gt; clsV(20,NULL);

//Declaration:
extern "C"
{
	void MySub (int *retVal, const int var1, const int var2, const int var3);
}

//Implementation:
void MySub (int *retVal, const int var1, const int var2, const int var3)
{
...

}[/cpp]&lt;/MYCLS&gt;&lt;/PRE&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is likely to do with argument passing/stack cleanup, since the call succeeds when the arguments are removed.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2010 17:25:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852625#M66528</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-06T17:25:41Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852626#M66529</link>
      <description>Can you construct a complete example and attach a ZIP of the solution/project folders? &lt;BR /&gt;&lt;BR /&gt;Also, please use "INTEGER, VALUE ::" instead of [VALUE], which is an undocumented Microsoft extension.</description>
      <pubDate>Tue, 06 Apr 2010 17:39:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852626#M66529</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-04-06T17:39:57Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852627#M66530</link>
      <description>Steve,&lt;BR /&gt;&lt;BR /&gt;Please find attached a zip of a cut-down project that reproduces the access violation - please see the comments in test1.for. The call succeeds when the C++ function is exported as stdcall, or when no arguments are passed, implying stack corruption. &lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Note that this is only reproducible in release mode. I have set debug info /debug:minimal in Console1.vfproj - if set to /debug:full the issue is not reproducible.&lt;/P&gt;&lt;P&gt;I am using compiler version 11.1.046 and Visual C++ 9.0.30729.1 (Visual Studio 2008 SP). &lt;/P&gt;Thanks for your help.</description>
      <pubDate>Wed, 07 Apr 2010 11:20:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852627#M66530</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-07T11:20:56Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852628#M66531</link>
      <description>It is not clear from you post as if you are on 32-bit or 64-bit system.&lt;BR /&gt;&lt;BR /&gt;On 64-bit all function calls are fastcall (pass first few values via registers)&lt;BR /&gt;&lt;BR /&gt;On 32-bit platform fastcall/ nofastcall is controlled by option switches, declspec, ATTRIBUTES etc.&lt;BR /&gt;&lt;BR /&gt;Check to make sure fastcall is consistent&lt;BR /&gt;&lt;BR /&gt;And, check to make sure int size is the same.&lt;BR /&gt;&lt;BR /&gt;Alternate way to check:&lt;BR /&gt;&lt;BR /&gt;Make a call to MySub from within the C++ side. Then compile both the Fortran and C++ modules making this call but add the option switch to produce the assembler output. Comparing the calling sequence might point you to the problem.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Apr 2010 13:06:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852628#M66531</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-04-07T13:06:45Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852629#M66532</link>
      <description>&lt;P&gt;I'm using a 32-bit system, and all integer types line up (4-bytes signed). I've also tried setting the value types to pointers and removing const in the function name but this didn't work.&lt;/P&gt;&lt;P&gt;I'll take a look at the assembler output and see if it reveals anything.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2010 13:25:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852629#M66532</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-07T13:25:13Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852630#M66533</link>
      <description>I tried this with 11.1.060 and saw no error. Can you try that?</description>
      <pubDate>Wed, 07 Apr 2010 14:16:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852630#M66533</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-04-07T14:16:17Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852631#M66534</link>
      <description>&lt;P&gt;I rebuilt using 11.1.060 and it runs fine on several machines. I have tested the "broken" version (11.1.046) on the same machines (both running in debugger and from command line) and get the same access violation issue. Is there any chance you could also test with 11.1.046 as a sanity check, in case some environment setting is causing the problem?&lt;/P&gt;&lt;P&gt;If this is a compiler issue, it possible to request a patch for compiler version 11.1.046? I don't think moving to a later compiler release is an option for us right now as we are gearing up for a release and would need to extensively re-test everything if using a newer compiler.&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2010 16:05:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852631#M66534</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-07T16:05:24Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852632#M66535</link>
      <description>Yes, I can reproduce it using 11.1.048. We don't do "patches" - we fix issues by releasing an update that installs a new compiler. I verified that indeed version 048 does not pop the stack after the call and version 060 does. However, I am unable to identify which problem report in our database led to this fix, not that knowing this would help you.</description>
      <pubDate>Wed, 07 Apr 2010 17:09:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852632#M66535</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-04-07T17:09:23Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852633#M66536</link>
      <description>&lt;P&gt;I still can't quite understand why this problem occurs in the attached project but not in other parts of my program where I am essentially doing the same thing: in the working cases I am passing in parameters of various types, including the first element of an assumed-shape array of reals, as well as single-byte and 4-byte ints. In fact, when I run the cut-down example with exactly the code that works in the project proper, it still fails. This had me thinking that I had not initialised something correctly, or that it was a calling convention issue, but doesn't explain why some examples succeed and others don't where all environment/project settings match.&lt;/P&gt;&lt;P&gt;In the release notes there is a reference to DPD200148942  Fortran  Internal Compiler Error on Function returning pointer with BIND(C) which may be the fix.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2010 13:28:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852633#M66536</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-08T13:28:00Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852634#M66537</link>
      <description>No, that issue is not related. The thing with the stack corruption is that you don't always see a symptom.</description>
      <pubDate>Thu, 08 Apr 2010 14:18:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852634#M66537</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-04-08T14:18:06Z</dc:date>
    </item>
    <item>
      <title>BIND C or !DEC$ ATTRIBUTES C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852635#M66538</link>
      <description>&lt;P&gt;As it's a compiler bug I think our only option is to move to version 060 when possible - sooner rather than later if it's only luck that we've not witnessed stack corruption until now! &lt;/P&gt;&lt;P&gt;Note that the problem is only evident when passing pointer variables to C, not value types.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2010 14:46:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/BIND-C-or-DEC-ATTRIBUTES-C/m-p/852635#M66538</guid>
      <dc:creator>Martin__Paul</dc:creator>
      <dc:date>2010-04-08T14:46:36Z</dc:date>
    </item>
  </channel>
</rss>

