<?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 Steve, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013639#M106589</link>
    <description>&lt;P&gt;Steve,&lt;/P&gt;

&lt;P&gt;I do not think this "violates" the aliasing rules. Rather, this is an exemplar of "using arguments that alias one another may produce unpredictable results".&lt;/P&gt;

&lt;P&gt;Perhaps there could be a compiler option or better,&amp;nbsp;!DEC$,&amp;nbsp;that generates warnings for arguments that alias.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
    <pubDate>Sat, 02 Aug 2014 12:45:24 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2014-08-02T12:45:24Z</dc:date>
    <item>
      <title>Inconsistency between arguments, Valid ?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013636#M106586</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm wondering is the following code is valid.&lt;/P&gt;

&lt;P&gt;I'm defining a type bound procedure which has 2 argument:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;the passed-object dummy argument with the attribute 'intent(inout)'&lt;/LI&gt;
	&lt;LI&gt;a integer variable with the attribute 'intent(in)'&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;If the actual argument associated to the dummy argument n°2 is a component of the passed-object dummy argument and if this component is modified in the TBP, then there is an inconsistency since the argument n°2 is declared as 'intent(in)' but its value is actually changing.&lt;/P&gt;

&lt;P&gt;Below, an example which run without any warnings or errors&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;! ifort main.f90; ./a.out
Module MyModule
  implicit none
  private
  public        ::      MyType
  Type          ::      MyType
    integer     ::      Var
  contains
    procedure   ,public ::      Do_Something_Inconsistent
  End Type
  contains
Subroutine Do_Something_Inconsistent( This, Var )
  class(MyType)         ,intent(inout)  ::      This
  integer               ,intent(in)     ::      Var
  This%Var      =       Var + 1
End Subroutine
End Module
Program Main
  use MyModule  ,only:  MyType
  implicit none
  type(MyType)  ::      Obj
  Obj%Var       =       1       
  write(*,"('BEFORE: Obj%Var = ',g0)") Obj%Var
  call Obj%Do_Something_Inconsistent( Obj%Var )         ! Is this valid
  write(*,"('AFTER:  Obj%Var = ',g0)") Obj%Var
End Program&lt;/PRE&gt;

&lt;P&gt;sd&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2014 15:51:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013636#M106586</guid>
      <dc:creator>FlyingHermes</dc:creator>
      <dc:date>2014-07-30T15:51:07Z</dc:date>
    </item>
    <item>
      <title>It's not legal Fortran, as it</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013637#M106587</link>
      <description>&lt;P&gt;It's not legal Fortran, as it violates the aliasing rules, but a compiler is not required to diagnose it. Intent has nothing to do with it other than it is the programmer's promise as to what will happen.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2014 15:54:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013637#M106587</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-07-30T15:54:39Z</dc:date>
    </item>
    <item>
      <title>Enclosing the argument in</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013638#M106588</link>
      <description>&lt;P&gt;Enclosing the argument in parentheses should make the call valid:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;call Obj%Do_Something_Inconsistent( ( Obj%Var ) )&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 01:27:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013638#M106588</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2014-08-02T01:27:29Z</dc:date>
    </item>
    <item>
      <title>Steve,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013639#M106589</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;

&lt;P&gt;I do not think this "violates" the aliasing rules. Rather, this is an exemplar of "using arguments that alias one another may produce unpredictable results".&lt;/P&gt;

&lt;P&gt;Perhaps there could be a compiler option or better,&amp;nbsp;!DEC$,&amp;nbsp;that generates warnings for arguments that alias.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 12:45:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013639#M106589</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-08-02T12:45:24Z</dc:date>
    </item>
    <item>
      <title>It's not that simple. The</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013640#M106590</link>
      <description>&lt;P&gt;It's not that simple. The standard doesn't prohibit aliasing, per se, but it restricts what you can do if arguments are aliased, depending on argument attributes. In this case, the program violates the rules of the following section, in particular (3) and (4):&lt;/P&gt;

&lt;P&gt;1 12.5.2.13 Restrictions on entities associated with dummy arguments&lt;BR /&gt;
	&lt;BR /&gt;
	2 1 While an entity is associated with a dummy argument, the following restrictions hold.&lt;BR /&gt;
	&lt;BR /&gt;
	3 (1) Action that affects the allocation status of the entity or a subobject thereof shall be taken through&lt;BR /&gt;
	4 the dummy argument.&lt;BR /&gt;
	5 (2) If the allocation status of the entity or a subobject thereof is affected through the dummy argument,&lt;BR /&gt;
	6 then at any time during the invocation and execution of the procedure, either before or after the&lt;BR /&gt;
	7 allocation or deallocation, it shall be referenced only through the dummy argument.&lt;BR /&gt;
	8 (3) Action that affects the value of the entity or any subobject of it shall be taken only through the&lt;BR /&gt;
	9 dummy argument unless&lt;BR /&gt;
	10 (a) the dummy argument has the POINTER attribute or&lt;BR /&gt;
	11 (b) the dummy argument has the TARGET attribute, the dummy argument does not have INTENT&lt;BR /&gt;
	12 (IN), the dummy argument is a scalar object or an assumed-shape array without the CONTI-&lt;BR /&gt;
	13 GUOUS attribute, and the actual argument is a target other than an array section with a&lt;BR /&gt;
	14 vector subscript.&lt;BR /&gt;
	15 (4) If the value of the entity or any subobject of it is affected through the dummy argument, then at&lt;BR /&gt;
	16 any time during the invocation and execution of the procedure, either before or after the definition,&lt;BR /&gt;
	17 it may be referenced only through that dummy argument unless&lt;BR /&gt;
	18 (a) the dummy argument has the POINTER attribute or&lt;BR /&gt;
	19 (b) the dummy argument has the TARGET attribute, the dummy argument does not have INTENT&lt;BR /&gt;
	20 (IN), the dummy argument is a scalar object or an assumed-shape array without the CONTI-&lt;BR /&gt;
	21 GUOUS attribute, and the actual argument is a target other than an array section with a&lt;BR /&gt;
	22 vector subscript.&lt;/P&gt;

&lt;P&gt;This is not something detectable without generating run-time checking code and it's complex. We do have an option, /assume:dummy_alias, which will effectively remove this restriction by disabling certain optimizations.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 17:53:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013640#M106590</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-08-02T17:53:47Z</dc:date>
    </item>
    <item>
      <title>What is the effect of</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013641#M106591</link>
      <description>&lt;P&gt;What is the effect of enclosing the argument in parentheses ?&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 19:50:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013641#M106591</guid>
      <dc:creator>FlyingHermes</dc:creator>
      <dc:date>2014-08-02T19:50:23Z</dc:date>
    </item>
    <item>
      <title>Trying this program will show</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013642#M106592</link>
      <description>&lt;P&gt;Trying this program will show you the effect (in essence, the variable becomes an expression):&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program xparen
implicit none
integer :: i=3

call sub(i)
write(*,*)i

call sub((i))
write(*,*)i

end program xparen

subroutine sub(i)
implicit none
integer :: i
i=i+1
return
end subroutine sub&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 20:33:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013642#M106592</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-08-02T20:33:25Z</dc:date>
    </item>
    <item>
      <title>And the effect of that is</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013643#M106593</link>
      <description>&lt;P&gt;And the effect of that is that a temporary copy of the value is passed - that copy can be modified but the modifications are discarded when the procedure returns.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Aug 2014 23:45:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013643#M106593</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-08-02T23:45:49Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013644#M106594</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;And the effect of that is that a temporary copy of the value is passed - that copy can be modified but the modifications are discarded when the procedure returns.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;To avoid any misunderstandings, let me point out that what Steve said is practically true of the Intel implementation and most other implementations, but it is almost backwards with respect to the standard.&amp;nbsp; The standard expects the expression to be evaluated as part of the procedure invocation and that it should remain unchanged throughout the execution of the procedure.&amp;nbsp; (Indeed, some implementations put the value of some expressions in read-only memory to give them hardware protection against being changed.) &amp;nbsp; By copying the value of the expression into a temporary location, the implementation makes it possible to change the value of the original variable without modifying the previously computed value of the expression.&lt;/P&gt;

&lt;P&gt;Steve's description is much closer to the standard's idea of the effect of the VALUE attribute on a dummy argument.&lt;/P&gt;

&lt;P&gt;-Kurt&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2014 23:27:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013644#M106594</guid>
      <dc:creator>Hirchert__Kurt_W</dc:creator>
      <dc:date>2014-08-04T23:27:33Z</dc:date>
    </item>
    <item>
      <title>Quote:mecej4 wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013645#M106595</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;mecej4 wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Trying this program will show you the effect (in essence, the variable becomes an expression):&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program xparen
implicit none
integer :: i=3

call sub(i)
write(*,*)i

call sub((i))
write(*,*)i

end program xparen

subroutine sub(i)
implicit none
integer :: i
i=i+1
return
end subroutine sub&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;For the record, this program will work in Intel's implementation and many others, but it does not conform to the Fortran standard, because one is not allowed to redefined a dummy argument associated with an actual argument that is an expression.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2014 23:31:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013645#M106595</guid>
      <dc:creator>Hirchert__Kurt_W</dc:creator>
      <dc:date>2014-08-04T23:31:49Z</dc:date>
    </item>
    <item>
      <title>sd could use VALUE in place</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013646#M106596</link>
      <description>&lt;P&gt;sd could use VALUE in place of intent(in) to provide some measure of protection in event that the input argument would unexpectedly change through the modification of an intent(inout) variable. This way, sd won't have to hunt down all calls and add () where appropriate.&lt;/P&gt;

&lt;P&gt;That said, the code could conceivably have been written to obfuscate the fact that the intention was to expressly modify the intent(in) variable.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2014 15:01:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013646#M106596</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-08-05T15:01:31Z</dc:date>
    </item>
    <item>
      <title>hrichert728 is correct.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013647#M106597</link>
      <description>&lt;P&gt;hrichert728 is correct.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2014 15:27:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Inconsistency-between-arguments-Valid/m-p/1013647#M106597</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-08-05T15:27:46Z</dc:date>
    </item>
  </channel>
</rss>

