problems with overindexing

problems with overindexing

Hello Everybody,

I am having problems compiling the following simple program that uses "overindexing":

REAL, DIMENSION(20,20) :: a
INTEGER, PARAMETER :: n = size(a)
INTEGER :: i, j

a(:n,1) = 10.0


Despite using the compiler switch -WB, this is what
I am getting:

a(:n,1) = 10.0
Error 172 at (7:overindex.f90) : Not all section elements are within array bounds

I successfully compiled this program using other FORTRAN
90/95 compilers, such as, e.g. Lahey. According to Intel
documentation, the switch -WB should turn off checking
for out-of-bounds indices.

Am I doing something wrong, or is this a bug? Any advice
will be greatly appreciated. Thanks!


Bartek Protas

Compiler specs:
Intel Fortran Compiler for 32-bit applications, Version 7.1 Build 20030307Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

-WB simply converts a bounds violation to a warning instead of an error, Are you also specifying -CB or -C? These turn on bounds checking.

The code is illegal, of course, and results may be unpredictable.


Retired 12/31/2016

Hi Steve,

Thanks for your reply. Nope, I am not using any of the
-C switches. Is seems to me that -WB is not doing what it
should be doing.

I realize that overindexing is illegal, but I have a
huge code that (ab)uses this convention. Any idea as to how
to get around that using 'ifc', or should I rather rewrite
the code? Thanks!


Actually, -WB affects run-time bounds checking only. In your case, it's the compiler that is detecting the problem, and I don't see a way to turn that off. I note that the upcoming version 8.0 will let you get away with this.

Looks as if you'll need to rewrite it (and I would recommend doing so in a legal fashion) for use with 7.1.


Retired 12/31/2016

I think the primary reason for the -WB switch is to permit the practice, obsoleted 25 years ago, of using dimension (1) instead of (*) (f77 notation).

I suppose, in your example, it would be better to write

a(:,:) = 10.0

It does look like there is an inconsistency between the documentation and implementation of the -WB switch. Maybe it's intended only to work (loosely speaking) with the f77 subset of Fortran, like some other extensions.

Leave a Comment

Please sign in to add a comment. Not a member? Join today