<?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 passing optional arguments in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009157#M105529</link>
    <description>&lt;P&gt;I am using Fortran Compiler XE 15.0.1.148 .&lt;/P&gt;

&lt;P&gt;When I compile and run the attached program, it crashes with an access violation.&amp;nbsp; The error occurs when an optional array section, that is not present, is passed to another subroutine.&amp;nbsp; There are no errors when I compile the same program with gfortran (4.9.1).&lt;/P&gt;

&lt;P&gt;I am not sure if the bug is in the Fortran program, or the compiler.&amp;nbsp; I have checked the standard, and it is not clear if this is allowed.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	12.5.2.12 Argument presence and restrictions on arguments not present&lt;/P&gt;

&lt;P&gt;3 An optional dummy argument that is not present is subject to the following restrictions.&lt;/P&gt;

&lt;P&gt;(1) If it is a data object, it shall not be referenced or be defined. If it is of a type that has default initialization, the initialization has no effect.&lt;BR /&gt;
	...&amp;nbsp; 11 other restrictions.&lt;/P&gt;

&lt;P&gt;4 Except as noted in the list above, it may be supplied as an actual argument corresponding to an optional dummy argument, which is then also considered not to be present.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Roman&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Dec 2014 19:49:14 GMT</pubDate>
    <dc:creator>Roman1</dc:creator>
    <dc:date>2014-12-02T19:49:14Z</dc:date>
    <item>
      <title>passing optional arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009157#M105529</link>
      <description>&lt;P&gt;I am using Fortran Compiler XE 15.0.1.148 .&lt;/P&gt;

&lt;P&gt;When I compile and run the attached program, it crashes with an access violation.&amp;nbsp; The error occurs when an optional array section, that is not present, is passed to another subroutine.&amp;nbsp; There are no errors when I compile the same program with gfortran (4.9.1).&lt;/P&gt;

&lt;P&gt;I am not sure if the bug is in the Fortran program, or the compiler.&amp;nbsp; I have checked the standard, and it is not clear if this is allowed.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	12.5.2.12 Argument presence and restrictions on arguments not present&lt;/P&gt;

&lt;P&gt;3 An optional dummy argument that is not present is subject to the following restrictions.&lt;/P&gt;

&lt;P&gt;(1) If it is a data object, it shall not be referenced or be defined. If it is of a type that has default initialization, the initialization has no effect.&lt;BR /&gt;
	...&amp;nbsp; 11 other restrictions.&lt;/P&gt;

&lt;P&gt;4 Except as noted in the list above, it may be supplied as an actual argument corresponding to an optional dummy argument, which is then also considered not to be present.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Roman&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2014 19:49:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009157#M105529</guid>
      <dc:creator>Roman1</dc:creator>
      <dc:date>2014-12-02T19:49:14Z</dc:date>
    </item>
    <item>
      <title>You have almost answered your</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009158#M105530</link>
      <description>&lt;P&gt;You have almost answered your own question. The line in question, line-15, attempts to extract a section of an array variable when that variable is not present. Taking a section amounts to making a reference, I think.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2014 20:13:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009158#M105530</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-12-02T20:13:12Z</dc:date>
    </item>
    <item>
      <title>I would say that your program</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009159#M105531</link>
      <description>&lt;P&gt;I would say that your program, which has:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;call sub2( a(2:3) )&amp;nbsp;&lt;/P&gt;

&lt;P&gt;violates the following rule of the standard:&lt;/P&gt;

&lt;P&gt;12.5.2.12 Argument presence and restrictions on arguments not present&lt;/P&gt;

&lt;P&gt;An optional dummy argument that is not present is subject to the following restrictions:&lt;BR /&gt;
	...&lt;BR /&gt;
	(5) A designator with it as the base object and with one or more subobject selectors shall not be supplied as an actual argument.&lt;/P&gt;

&lt;P&gt;(2:3) is a subobject selector.&lt;/P&gt;

&lt;P&gt;You are allowed only to pass the whole array as an actual argument (to a procedure where the corresponding dummy is OPTIONAL), not a part of the array.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2014 20:16:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009159#M105531</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-12-02T20:16:27Z</dc:date>
    </item>
    <item>
      <title>Thanks for the explanation,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009160#M105532</link>
      <description>&lt;P&gt;Thanks for the explanation, it makes sense now.&amp;nbsp; I thought that restriction (5) was only for derived types.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2014 21:12:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009160#M105532</guid>
      <dc:creator>Roman1</dc:creator>
      <dc:date>2014-12-02T21:12:27Z</dc:date>
    </item>
    <item>
      <title>Yes, I can see how you might</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009161#M105533</link>
      <description>&lt;P&gt;Yes, I can see how you might assume that. I had to go read the definition to be sure.&lt;/P&gt;

&lt;P&gt;gfortran's behavior is an extension, though I wonder if it's deliberate.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2014 21:16:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-optional-arguments/m-p/1009161#M105533</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-12-02T21:16:37Z</dc:date>
    </item>
  </channel>
</rss>

