<?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 Bugs and ICE with transfer and character substring in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140969#M137168</link>
    <description>&lt;P&gt;I was writing a procedure to reverse characters on a string and found some bugs and even Internal Compiler Errors.&lt;/P&gt;&lt;P&gt;Consider this case:&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;program reverse
  implicit none
  character(20), parameter :: input = 'Forward'
  integer i
  character(len(input)), parameter :: output = &amp;amp;
     transfer([(input(i:i),i=len_trim(input),1,-1)],trim(input))
  print *, input, '#', len(input)
  print *, output, '#', len(output)
end program reverse
&lt;/PRE&gt;

&lt;P&gt;My expected output was:&lt;/P&gt;

&lt;PRE class="brush:; class-name:dark;"&gt; Forward             #          20
 drawroF             #          20
&lt;/PRE&gt;

&lt;P&gt;But I got this:&lt;/P&gt;

&lt;PRE class="brush:; class-name:dark;"&gt; Forward             #          20
 drawroF#           7
&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;I am getting a len=7 character parameter despite of declaring it as len=20. The trimmed length overwrites the declared length for some reason.&lt;/P&gt;
&lt;P&gt;Then, I tried changing the code to remove all trimming, like this:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;program reverse
  implicit none
  character(20), parameter :: input = 'Forward'
  integer i
  character(len(input)), parameter :: output = &amp;amp;
     transfer([(input(i:i),i=len(input),1,-1)],input)
  print *, input, '#', len(input)
  print *, output, '#', len(output)
end program reverse
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this produces an "internal error" on the line of the character declaration. Changing this line&amp;nbsp;again to:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;  character(len(input)), parameter :: output = &amp;amp;
     transfer([character::(input(i:i),i=len(input),1,-1)],input)&lt;/PRE&gt;

&lt;P&gt;Now produces a "catastrophic error: **Internal compiler error: segmentation violation signal raised**".&lt;/P&gt;</description>
    <pubDate>Sun, 27 Jan 2019 09:20:22 GMT</pubDate>
    <dc:creator>Rodrigo_R_</dc:creator>
    <dc:date>2019-01-27T09:20:22Z</dc:date>
    <item>
      <title>Bugs and ICE with transfer and character substring</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140969#M137168</link>
      <description>&lt;P&gt;I was writing a procedure to reverse characters on a string and found some bugs and even Internal Compiler Errors.&lt;/P&gt;&lt;P&gt;Consider this case:&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;program reverse
  implicit none
  character(20), parameter :: input = 'Forward'
  integer i
  character(len(input)), parameter :: output = &amp;amp;
     transfer([(input(i:i),i=len_trim(input),1,-1)],trim(input))
  print *, input, '#', len(input)
  print *, output, '#', len(output)
end program reverse
&lt;/PRE&gt;

&lt;P&gt;My expected output was:&lt;/P&gt;

&lt;PRE class="brush:; class-name:dark;"&gt; Forward             #          20
 drawroF             #          20
&lt;/PRE&gt;

&lt;P&gt;But I got this:&lt;/P&gt;

&lt;PRE class="brush:; class-name:dark;"&gt; Forward             #          20
 drawroF#           7
&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;I am getting a len=7 character parameter despite of declaring it as len=20. The trimmed length overwrites the declared length for some reason.&lt;/P&gt;
&lt;P&gt;Then, I tried changing the code to remove all trimming, like this:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;program reverse
  implicit none
  character(20), parameter :: input = 'Forward'
  integer i
  character(len(input)), parameter :: output = &amp;amp;
     transfer([(input(i:i),i=len(input),1,-1)],input)
  print *, input, '#', len(input)
  print *, output, '#', len(output)
end program reverse
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this produces an "internal error" on the line of the character declaration. Changing this line&amp;nbsp;again to:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark; wrap-lines:false;"&gt;  character(len(input)), parameter :: output = &amp;amp;
     transfer([character::(input(i:i),i=len(input),1,-1)],input)&lt;/PRE&gt;

&lt;P&gt;Now produces a "catastrophic error: **Internal compiler error: segmentation violation signal raised**".&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 09:20:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140969#M137168</guid>
      <dc:creator>Rodrigo_R_</dc:creator>
      <dc:date>2019-01-27T09:20:22Z</dc:date>
    </item>
    <item>
      <title>Additional info: I do get the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140970#M137169</link>
      <description>&lt;P&gt;Additional info:&amp;nbsp;I do get the desired output if I remove the `parameter` specifier from it.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 09:39:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140970#M137169</guid>
      <dc:creator>Rodrigo_R_</dc:creator>
      <dc:date>2019-01-27T09:39:33Z</dc:date>
    </item>
    <item>
      <title>Interesting code. Your first</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140971#M137170</link>
      <description>&lt;P&gt;Interesting code. Your first variant also introduces an ICE with the PGI compiler, nagfor and gfortran show the length as 20, but gfortran removes all blanks and prints only 7 characters, while nagfor prints 20 characters. Intel - as you noted - shows the length as 7 and prints only 7. An ICE (Internal Compiler Error) is always an error of the compiler, so please report this to Intel Online Support Center.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 10:48:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140971#M137170</guid>
      <dc:creator>Juergen_R_R</dc:creator>
      <dc:date>2019-01-27T10:48:46Z</dc:date>
    </item>
    <item>
      <title>I can see the first error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140972#M137171</link>
      <description>&lt;P&gt;I can see the first error with a number of versions of IFort - Windows. Even Compaq Visual Fortran 6.6C has this&amp;nbsp;error.&lt;/P&gt;&lt;P&gt;With Intel Fortran 14.0.6 (Windows), the second and third versions of the test program get compiled with no errors and the output is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 11:22:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Bugs-and-ICE-with-transfer-and-character-substring/m-p/1140972#M137171</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2019-01-27T11:22:23Z</dc:date>
    </item>
  </channel>
</rss>

