Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Bounds checking

lars_sune
Beginner
767 Views
Shouldn't /check:bounds catch these errors? I know these are stupid mistakes, but I tend to make stupid mistakes smiley [:-)]

program bounds

implicit none

double precision, allocatable :: A(:,:), B(:,:), C(:,:)
allocate( A(2,2), B(2,3), C(3,3) )

B = 1; C = 2

A = matmul( B, C )
print *, 'A = B*C passed'

A = matmul( C, B )
print *, 'A = C*B passed'

A = C
print *, 'A = C passed'

end program bounds


0 Kudos
4 Replies
Steven_L_Intel1
Employee
767 Views
Not necessarily - these are shape mismatch errors which the compiler does not detect at runtime. Bounds checking will look at explicit use of subscripts.
0 Kudos
lars_sune
Beginner
767 Views
Forgot to say which compiler version I am using. It is
Intel Fortran Compiler 10.1.014 [IA-32]
0 Kudos
lars_sune
Beginner
767 Views
OK. Is there a compiler option that does check for this? Seems like it would be a (relatively) easy thing to do.
0 Kudos
Steven_L_Intel1
Employee
767 Views
No - it's on our wish list, though.
0 Kudos
Reply