<?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 Optimization changes passing of arguments? (Compiler Bug?) in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824422#M49368</link>
    <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=126388" class="basic" href="https://community.intel.com/en-us/profile/126388/"&gt;Les Neilson&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="border: 1px inset; padding: 5px; background-color: #e5e5e5; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;BR /&gt;&lt;BR /&gt;Microsoft have put further obstacles inmy way by not allowing debugging of mixed (managed and unmanaged) code for 64bit compilation in VS2008.&lt;BR /&gt;Ihaven't been able tofind out if this restrictionis removed in VS2010&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, that's a pain. However, it is not allowed only to debug them &lt;B&gt;simultaneously &lt;/B&gt;(in the same debug session). If you want to debug only an unmanaged component, set it as a startup project, and set up the managed .exe as the "executable for debug session". Additionally, make sure that the debugger model in project settings is "Native only" (rather than "Automatic").&lt;/P&gt;</description>
    <pubDate>Fri, 21 May 2010 16:39:19 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2010-05-21T16:39:19Z</dc:date>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824412#M49358</link>
      <description>Following source code (in two diffent files)&lt;BR /&gt;&lt;BR /&gt;program testprj_fortran&lt;BR /&gt;&lt;BR /&gt; implicit none&lt;BR /&gt;&lt;BR /&gt; double precision:: d1(12)=(/1,2,3,4,5,6,7,8,9,0,0,0/)&lt;BR /&gt;&lt;BR /&gt; call swap(d1,d1)&lt;BR /&gt; write(*,*) d1&lt;BR /&gt; read(*,*)&lt;BR /&gt; end program testprj_fortran&lt;BR /&gt;&lt;BR /&gt;subroutine swap(dm1,dm2)&lt;BR /&gt; DOUBLE PRECISION DM1(12),DM2(12),DMH(9)&lt;BR /&gt; DMH(1)=DM1(1)&lt;BR /&gt; DMH(2)=DM1(4)&lt;BR /&gt; DMH(3)=DM1(7)&lt;BR /&gt; DMH(4)=DM1(2)&lt;BR /&gt; DMH(5)=DM1(5)&lt;BR /&gt; DMH(6)=DM1(8)&lt;BR /&gt; DMH(7)=DM1(3)&lt;BR /&gt; DMH(8)=DM1(6)&lt;BR /&gt; DMH(9)=DM1(9)&lt;BR /&gt; DM2(10)=DMH(1)*DM1(10)&lt;BR /&gt; DM2(11)=DMH(2)*DM1(10)&lt;BR /&gt; DM2(12)=DMH(3)*DM1(10)&lt;BR /&gt; DO I=1,9&lt;BR /&gt; DM2(I)=DMH(I)&lt;BR /&gt; enddo&lt;BR /&gt; END&lt;BR /&gt;&lt;BR /&gt;gives following output in Debug-Mode or when /Od is used (this is the correct result)&lt;BR /&gt; &lt;BR /&gt; 1.00000000000000 4.00000000000000 7.00000000000000&lt;BR /&gt; 2.00000000000000 5.00000000000000 8.00000000000000&lt;BR /&gt; 3.00000000000000 6.00000000000000 9.00000000000000&lt;BR /&gt; 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000&lt;BR /&gt;&lt;BR /&gt;but this in Release-Mode (which is wrong)&lt;BR /&gt;&lt;BR /&gt; 1.00000000000000 4.00000000000000 7.00000000000000&lt;BR /&gt; 2.00000000000000 5.00000000000000 8.00000000000000&lt;BR /&gt; 7.00000000000000 8.00000000000000 9.00000000000000&lt;BR /&gt; 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000&lt;BR /&gt;&lt;BR /&gt;I tried this with compiler versions 11.1.64, 11.1.60, 11.1.51, 11.0.74 and 10.1.25. All compilers give the same result.&lt;BR /&gt;&lt;BR /&gt;My Compiler Options in Release-Mode are:&lt;BR /&gt;&lt;BR /&gt;/nologo /module:"Release\\\\" /object:"Release\\\\" /libs:static /threads /c&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What is wrong? Any Ideas?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 07 May 2010 09:53:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824412#M49358</guid>
      <dc:creator>rwg</dc:creator>
      <dc:date>2010-05-07T09:53:36Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824413#M49359</link>
      <description>You pass d1 as input &amp;amp; output.&lt;BR /&gt;&lt;BR /&gt;The optimiser 'knows' that arrays will not overlap, so it recognises that DMH is an unneeded temporary array, and refactors to work directly with DM1 and DM2. This is why you get duplicates for 7 &amp;amp; 8. At different optimisation levels you might get different duplicates. You might be better off writing it as a function that returns an array.&lt;BR /&gt;&lt;BR /&gt;FUNCTION swap(d1) RESULT (d2)&lt;BR /&gt;REAL:: d2(UBOUND(d1)) ! Whatever is the correct syntax&lt;BR /&gt;...</description>
      <pubDate>Fri, 07 May 2010 13:53:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824413#M49359</guid>
      <dc:creator>bendel_boy1</dc:creator>
      <dc:date>2010-05-07T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824414#M49360</link>
      <description>Have a read of 12.4.1.7 in the Fortran 2003 standard (there's a link to it off the main page of the forum - similar words will be present in previous standards), particularly the example given in Note 12.29. &lt;BR /&gt;&lt;BR /&gt;That section places limits on what can be done to dummy arguments that are associated with the same (part of an) actual argument, without there being things like TARGET/POINTER attributes etc - you can't define any part of the dummy arguments that overlap. I think you are breaking those limits. All bets are off.&lt;BR /&gt;&lt;BR /&gt;An alternative work around to the (possibly better) function call suggestion would be to change the call to be: &lt;BR /&gt;&lt;PRE&gt;[fortran]call swap((d1),d1)
[/fortran]&lt;/PRE&gt;where the first dummy argument is then associated with an actual argument that is an expression (that happens to involve d1) and not directly to the variable d1. I think your code would then be standard conforming. &lt;BR /&gt;&lt;BR /&gt;Implementation detail (?) - but when the compiler sees the expression "(d1)" it will probably create a temporary array, fill that temporary with the value of d1 (as per the expression) and then call the swap procedure. The function call approach may also result in the creation of a temporary array, but it may avoid the need to fill (copy) the temporary with the value of d1 prior to the call. Regardless of that detail (and note that the optimiser may be smart enough to avoid temporaries and copies 
anyway) as the code with the expression or function call becomes standard conforming you can rely on the overall behaviour, which would be as you originally expected.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 May 2010 01:21:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824414#M49360</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2010-05-10T01:21:56Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824415#M49361</link>
      <description>&lt;P&gt;I have read chapter 12.4.1.7 of ISO/IEC FCD 1539-1:2004(E) (hope that's the document your refered to) but I can not see what it has to do with my example. Chapter 12.4.1.7 deals with references to outer defined variables (which is not the case in my example) and with defining, redefining and undefinig of arguments (which is also not done in my example). To avaid missunderstanding change swap to&lt;/P&gt;&lt;P&gt;subroutine swap(dm1,dm2)&lt;BR /&gt;DOUBLE PRECISION DM1(12),DM2(12),DMH(10)&lt;BR /&gt;DMH(1)=DM1(1)&lt;BR /&gt;DMH(2)=DM1(4)&lt;BR /&gt;DMH(3)=DM1(7)&lt;BR /&gt;DMH(4)=DM1(2)&lt;BR /&gt;DMH(5)=DM1(5)&lt;BR /&gt;DMH(6)=DM1(8)&lt;BR /&gt;DMH(7)=DM1(3)&lt;BR /&gt;DMH(8)=DM1(6)&lt;BR /&gt;DMH(9)=DM1(9)&lt;BR /&gt;DMH(10)=DM1(10)&lt;BR /&gt;DM2(10)=DMH(1)*DMH(10)&lt;BR /&gt;DM2(11)=DMH(2)*DMH(10)&lt;BR /&gt;DM2(12)=DMH(3)*DMH(10)&lt;BR /&gt;DO I=1,9&lt;BR /&gt;DM2(I)=DMH(I)&lt;BR /&gt;enddo&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;You can see that there isn'tan overlap of the dummy arguments during the assignments. But this example also fails.&lt;BR /&gt;DMH in swap was only added to make swap callablewith the same arguments and as far as I understand the FORTRAN Standard this has to be allowed. I think the optimizer of the FORTRAN Compiler did too much.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2010 06:25:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824415#M49361</guid>
      <dc:creator>rwg</dc:creator>
      <dc:date>2010-05-10T06:25:14Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824416#M49362</link>
      <description>That's the doc! The section I'm referring to is titled "Restrictions on entities associated with dummy arguments". Read note 12.29 which highlights an implication of the nearby normative text about action on an entity only being taken through &lt;SPAN style="text-decoration: underline;"&gt;the&lt;/SPAN&gt; (i.e. one) dummy argument. &lt;BR /&gt;&lt;BR /&gt;Assignment is&lt;I&gt; &lt;/I&gt;one way of defining a variable. Because you have &lt;SPAN style="text-decoration: underline;"&gt;two&lt;/SPAN&gt; dummy arguments (dm1 and dm2) associated with the same entity (d1) (and the dummies don't have target/pointer attributes etc) you cannot assign to any part of either of them. The order of assignments doesn't matter and the presence of the DMH variable doesn't matter.&lt;BR /&gt;&lt;BR /&gt;This restriction on aliasing is a Fortran language feature as it allows (or simplifies) certain optimisations.</description>
      <pubDate>Mon, 10 May 2010 12:09:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824416#M49362</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2010-05-10T12:09:35Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824417#M49363</link>
      <description>&lt;P&gt;I see you are absolutly right. Because of my restricted knowledge of the english language I didn't realize that 'define' included 'assign'.&lt;BR /&gt;&lt;BR /&gt;It's surprising that this 'error' does not appear if 'I don't assign values to DM2(10:12) and that these assignments destroy DM2(1:9)!&lt;BR /&gt;&lt;BR /&gt;I have lots of F77 programs where this type of argument passing is done. In most cases this works without any error. Is there a rule when this type of argument passing fails?&lt;BR /&gt;&lt;BR /&gt;In F77 this was common practice so I think this restriction came with F90,F95 or F2003. Does someone know?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2010 13:15:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824417#M49363</guid>
      <dc:creator>rwg</dc:creator>
      <dc:date>2010-05-10T13:15:59Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824418#M49364</link>
      <description>Nope - it was illegal in F77 as well. Some earlier compilers didn't try to optimize dummy arguments, but even VAX Fortran, a F77 compiler did. There is a /assume:dummy_aliases option which will disable such optimizations, but I'd recommend that you restructure the code to be legal Fortran instead.</description>
      <pubDate>Mon, 10 May 2010 13:58:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824418#M49364</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-10T13:58:28Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824419#M49365</link>
      <description>This is a good example of where a working program (that may have been working for decades) is not assurance that the program is bug-free.&lt;BR /&gt;&lt;BR /&gt;In the Northern latitudes this is what we would call "Walking on thin ice". The fact that you have walked across a frozen pond does not assure you that it is safe to walk across that frozen pond. (does not assure that the ice is thick enough to safely walk across). &lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&lt;EM&gt;It's surprising that this 'error' does not appear if 'I don't assign values to DM2(10:12) and that these assignments destroy DM2(1:9)!&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;This is a case where the 'symptom' of the programming error does not appear. (or had not appeared for a long time)&lt;BR /&gt;&lt;BR /&gt;Another way to think of this is a single threaded analog of what occures in a multi-threaded race condition. The way the code was written, the compiler was free to rearrange the statements to produce the stated results. Or you could say the compiler had more liberties than you assumed/experienced.&lt;BR /&gt;&lt;BR /&gt;If you have many such subroutines/functions that have this problem then by disabling optimizations for these subroutines/functions may reduce/eliminate the 'symptom' although it will not correct the programming error.&lt;BR /&gt;&lt;BR /&gt;If you want the optimizations for the cases when the dummy args do not overlap, yet permit occasional calls with overlappingdummies, then you will need to insert a test for overlapping dummies .or. create a new function/subroutine where you test for same dummies, overlapping dummies, non-overlapping dummies.&lt;BR /&gt;&lt;BR /&gt;Jim Demspey</description>
      <pubDate>Mon, 10 May 2010 14:57:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824419#M49365</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-05-10T14:57:45Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824420#M49366</link>
      <description>The late E.W.Dijkstra, a great man, wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;"computing's central challenge, viz. 'How not to make a mess of it', has not
 been met"&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;That dictum applies very well here. &lt;BR /&gt;&lt;BR /&gt;That you have code in which some rules of Fortran were broken yet worked correctly has the hallmarks of a self-made trap. There is no guaranteed penalty (i.e., wrong results) for writing buggy code. However, escaping from penalty is not guaranteed, either.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 21 May 2010 15:10:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824420#M49366</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-05-21T15:10:36Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824421#M49367</link>
      <description>&lt;BR /&gt;Alas when working with legacy libraries, some 25+ years old, these things crop up.&lt;BR /&gt;Just this week I found the same problem&lt;BR /&gt;&lt;BR /&gt;subroutine trans(matrix, inar, outar)&lt;BR /&gt;calculate tempar as function of matrix and inar&lt;BR /&gt;assign tempar to outar&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;call trans(mat, p1, p1)&lt;BR /&gt;appeared in lots of places&lt;BR /&gt;&lt;BR /&gt;Interestingly :&lt;BR /&gt;32bit debug and release worked ok&lt;BR /&gt;64bit debug worked ok&lt;BR /&gt;64bit release failed :-(&lt;BR /&gt;&lt;BR /&gt;It took me several days to track down the problem (using print statements)especially as debug 64bit worked.&lt;BR /&gt;&lt;BR /&gt;No doubt there are other pieces of code doing similar things waiting to trip me up.&lt;BR /&gt;&lt;BR /&gt;Les&lt;BR /&gt;&lt;BR /&gt;PS &lt;BR /&gt;Microsoft have put further obstacles inmy way by not allowing debugging of mixed (managed and unmanaged) code for 64bit compilation in VS2008.&lt;BR /&gt;Ihaven't been able tofind out if this restrictionis removed in VS2010&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 21 May 2010 16:07:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824421#M49367</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2010-05-21T16:07:59Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824422#M49368</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=126388" class="basic" href="https://community.intel.com/en-us/profile/126388/"&gt;Les Neilson&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="border: 1px inset; padding: 5px; background-color: #e5e5e5; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;BR /&gt;&lt;BR /&gt;Microsoft have put further obstacles inmy way by not allowing debugging of mixed (managed and unmanaged) code for 64bit compilation in VS2008.&lt;BR /&gt;Ihaven't been able tofind out if this restrictionis removed in VS2010&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, that's a pain. However, it is not allowed only to debug them &lt;B&gt;simultaneously &lt;/B&gt;(in the same debug session). If you want to debug only an unmanaged component, set it as a startup project, and set up the managed .exe as the "executable for debug session". Additionally, make sure that the debugger model in project settings is "Native only" (rather than "Automatic").&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2010 16:39:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824422#M49368</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-05-21T16:39:19Z</dc:date>
    </item>
    <item>
      <title>Optimization changes passing of arguments? (Compiler Bug?)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824423#M49369</link>
      <description>&lt;BLOCKQUOTE&gt;Microsoft have put further obstacles inmy way by not allowing debugging
 of mixed (managed and unmanaged) code for 64bit compilation in VS2008.&lt;BR /&gt;Ihaven't
 been able tofind out if this restrictionis removed in VS2010&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;&lt;BR /&gt;Microsoft appears to claim that this works in VS 2010 if the .NET code uses the .NET Framework 4.0. I have not yet been able to verify this.</description>
      <pubDate>Fri, 21 May 2010 17:25:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Optimization-changes-passing-of-arguments-Compiler-Bug/m-p/824423#M49369</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-05-21T17:25:30Z</dc:date>
    </item>
  </channel>
</rss>

