- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have run into a strange problem that was not diagnosed by ifort even with the -check all -warn all flags. The short code attached to this message compiles without complaning, but then produces wrong results (an array with intent(in) gets modified). There is a bug in the code, which is that the dimension of the c array is in this case (2,19) whereas the dimensions of y are (2,39). However, ifort doesn't pick this up, and instead produces wrong results.
I am using
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090827 Package ID: m_cprof_p_11.1.067
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifort can't pick this up because you prevented it from doing so. In routine b, you declared array y as (2*nx-1). The compiler takes your word for it and uses that as the dimension. If you had declared y as (:) instead not only would this avoid making a temporary copy for the non-contiguous array slice you pass, but now you'd get a run-time error like this:
forrtl: severe (408): fort: (2): Subscript #1 of the array Y has value 20 which is greater than the upper bound of 19
forrtl: severe (408): fort: (2): Subscript #1 of the array Y has value 20 which is greater than the upper bound of 19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the OP was hoping for a compile-time warning. Often, the compiler will warn if the actual array argument is too small, but I think that only works when the actual and dummy arguments both have a static size.
For example, change the subroutine b dummy argument to "y(100)" and the actual argument in the call from routine a to "C(1,1:5)". Then, both sizes are static, and 5 is too small, giving this error:
ifort_bug.f90(35): error #7983: The storage extent of the dummy argument exceeds that of the actual argument.
call b(size(x), c(1, 1:4), x)
--------------------^
Not also that a larger actual argument does not produce a warning.
For example, change the subroutine b dummy argument to "y(100)" and the actual argument in the call from routine a to "C(1,1:5)". Then, both sizes are static, and 5 is too small, giving this error:
ifort_bug.f90(35): error #7983: The storage extent of the dummy argument exceeds that of the actual argument.
call b(size(x), c(1, 1:4), x)
--------------------^
Not also that a larger actual argument does not produce a warning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the original example, the compiler does not know, at compile time, what the extent of the actual argument is.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page