<?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 Limitations on array slice bounds checking in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Limitations-on-array-slice-bounds-checking/m-p/1037105#M112078</link>
    <description>&lt;P&gt;I recently ran into an issue with assignment of incompatible array sections to an allocatable array that was not caught by the Intel Fortran compiler's bounds checking. &amp;nbsp;A reduced example is:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;subroutine sub1(array)
  implicit none

  real, intent(inout) :: array(42)
  real, allocatable :: send(:)

  allocate(send(1))
  send(:) = array(9:10)
end subroutine


! subroutine sub2(array)
!   implicit none
! 
!   real, intent(inout) :: array(42)
!   real :: send(1)
! 
!   send(:) = array(9:10)
! end subroutine


program bug
  implicit none

  real :: array(42)

  array = 0.0
  call sub1(array)
!   call sub2(array)

end program
&lt;/PRE&gt;

&lt;P&gt;Subroutines sub1 and sub2 assign an array section of size two into an array section of size one. &amp;nbsp;Obviously, this is illegal. &amp;nbsp;The version in sub2, which assigns to an ordinary array, is diagnosed at compile time when bounds checking is on. &amp;nbsp;The version in sub1, which assigns to an allocatable array, is not caught at compile time or at run time.&lt;/P&gt;

&lt;P&gt;Is this the expected behavior? &amp;nbsp;If so, are the capabilities and/or limitations of Intel Fortran's array bounds checking documented anywhere?&lt;/P&gt;

&lt;P&gt;This result was obtained with Intel Fortran&amp;nbsp;&lt;SPAN class="s1"&gt;15.0.1 20141022 on Mac OS X 10.10.1.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2015 19:48:46 GMT</pubDate>
    <dc:creator>Brian1</dc:creator>
    <dc:date>2015-03-05T19:48:46Z</dc:date>
    <item>
      <title>Limitations on array slice bounds checking</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Limitations-on-array-slice-bounds-checking/m-p/1037105#M112078</link>
      <description>&lt;P&gt;I recently ran into an issue with assignment of incompatible array sections to an allocatable array that was not caught by the Intel Fortran compiler's bounds checking. &amp;nbsp;A reduced example is:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;subroutine sub1(array)
  implicit none

  real, intent(inout) :: array(42)
  real, allocatable :: send(:)

  allocate(send(1))
  send(:) = array(9:10)
end subroutine


! subroutine sub2(array)
!   implicit none
! 
!   real, intent(inout) :: array(42)
!   real :: send(1)
! 
!   send(:) = array(9:10)
! end subroutine


program bug
  implicit none

  real :: array(42)

  array = 0.0
  call sub1(array)
!   call sub2(array)

end program
&lt;/PRE&gt;

&lt;P&gt;Subroutines sub1 and sub2 assign an array section of size two into an array section of size one. &amp;nbsp;Obviously, this is illegal. &amp;nbsp;The version in sub2, which assigns to an ordinary array, is diagnosed at compile time when bounds checking is on. &amp;nbsp;The version in sub1, which assigns to an allocatable array, is not caught at compile time or at run time.&lt;/P&gt;

&lt;P&gt;Is this the expected behavior? &amp;nbsp;If so, are the capabilities and/or limitations of Intel Fortran's array bounds checking documented anywhere?&lt;/P&gt;

&lt;P&gt;This result was obtained with Intel Fortran&amp;nbsp;&lt;SPAN class="s1"&gt;15.0.1 20141022 on Mac OS X 10.10.1.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2015 19:48:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Limitations-on-array-slice-bounds-checking/m-p/1037105#M112078</guid>
      <dc:creator>Brian1</dc:creator>
      <dc:date>2015-03-05T19:48:46Z</dc:date>
    </item>
    <item>
      <title>You're asking for "shape</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Limitations-on-array-slice-bounds-checking/m-p/1037106#M112079</link>
      <description>&lt;P&gt;You're asking for "shape checking", which we don't do. Sometimes bounds checking will spot problems on assignment, but not always.&lt;/P&gt;

&lt;P&gt;I will note that if you compile with -standard-semantics and remove the (:) from the references to send, then sub1 will work correctly as send will get automatically reallocated to the correct shape. You shouldn't use (:) unless you explicitly want to disable the standard's automatic reallocation feature. (See&amp;nbsp;https://software.intel.com/en-us/blogs/2008/03/31/doctor-it-hurts-when-i-do-this)&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2015 20:41:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Limitations-on-array-slice-bounds-checking/m-p/1037106#M112079</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-03-05T20:41:47Z</dc:date>
    </item>
  </channel>
</rss>

