Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: g95 wish list
In article <87ekig1p2r.fsf@vega.site>, Richard Maine
<nospam@see.signature> writes
>Andy Vaught <andy@firstinter.net> writes:
> 
>
>Yes, making these completely equivalent makes it impossible to do
>bounds checking on arrays that actually *DO* have bounds of 1. Such
>arrays exist.  Disabling bounds checking on them would be a shortcomming.
>
>I've seen compilers where there were command-line switches to enable
>this hack.  If one feels the need to support bounds checking for old
>codes with this hack, I'd say that made a lot more sense than
>crippling bounds checking so that it can never work on some arrays.
>
I don't follow this. If you treat DIMENSION X(1) as DIMENSION X(*) and
an array with one element in it is passed, it's perfectly possible to
have a bounds check which fails if the subroutine references X(2).

There are, and have been for years, compilers which do bounds-checking
on arrays with bounds of * (this is one of the tests in the Polyhedron
benchmarks).

The only problem I can see is that if you always treat 1 as *, you lose
the possibility of a check as to whether you passed an array of size 2
to a subroutine where it is declared explicitly as size 1 and was
actually supposed to be size 1. Both you and the compiler would have to
be psychic to pick this one up in any case.

Catherine.
--
Catherine Rees Lay
To email me, use my first name in front of the "at".

Report this thread to moderator Post Follow-up to this message
Old Post
Catherine Rees Lay
11-30-04 02:04 PM


Re: g95 wish list
Catherine Rees Lay wrote:

(big snip on dimension of (1) in various places)

> I don't follow this. If you treat DIMENSION X(1) as DIMENSION X(*) and
> an array with one element in it is passed, it's perfectly possible to
> have a bounds check which fails if the subroutine references X(2).

I hadn't noticed that, either.   I am not sure what any version
of the standard says about non-matching dimensions in subroutines
and subroutine callers.

> There are, and have been for years, compilers which do bounds-checking
> on arrays with bounds of * (this is one of the tests in the Polyhedron
> benchmarks).

Well, it does get complicated in some of the cases being
discussed.  Some other languages commonly use call by descriptor
for arrays, allowing the full dimension information to be
passed, but not allowing some of the other Fortran tricks that
have been described here.  It should be possible, and not all
that hard with the computer power available to do this.

One could even use the trick of a link time fixup I described
earlier.  Ugly, but it works.

> The only problem I can see is that if you always treat 1 as *, you lose
> the possibility of a check as to whether you passed an array of size 2
> to a subroutine where it is declared explicitly as size 1 and was
> actually supposed to be size 1. Both you and the compiler would have to
> be psychic to pick this one up in any case.

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
11-30-04 02:04 PM


Re: g95 wish list

Catherine Rees Lay wrote:
> In article <87ekig1p2r.fsf@vega.site>, Richard Maine
> <nospam@see.signature> writes
> 
> I don't follow this. If you treat DIMENSION X(1) as DIMENSION X(*) and
> an array with one element in it is passed, it's perfectly possible to
> have a bounds check which fails if the subroutine references X(2).
>
> There are, and have been for years, compilers which do bounds-checking
> on arrays with bounds of * (this is one of the tests in the Polyhedron
> benchmarks).
>
> The only problem I can see is that if you always treat 1 as *, you lose
> the possibility of a check as to whether you passed an array of size 2
> to a subroutine where it is declared explicitly as size 1 and was
> actually supposed to be size 1. Both you and the compiler would have to
> be psychic to pick this one up in any case.

There are two levels to the bounds checking problem. The first level is
whether the subscripts are within the bounds that are declared for the
array, whether it is an argument or not. The second level is whether
the declaration of a dummy argument is compatible with the actual
argument supplied. The first level is easy and the second level is
hard, under the assumption of an implementation which is trying to
add subscript checking on as an after thought. WatFor, Salford etc show
that it is easy if the checking is designed in. In the after thought
scheme a "*" often translates into don't bother. The historical side
confusion is that since the last dimension is "irrelevant" for an
argument in some implementations the habit had grown up of supplying
anything for the last dimension, which was tamed to using "1" and then
formalized to "*".

F90 changed everything with ":" and even permitted multiple ":"s while
F77 permitted only one "*" and it had to be the last dimension.
Supporting ":" before it was introduced was the secret behind WatFor,
Salford etc. Different terminology for the same notions, and subject
to different technical requirements

> Catherine.

Report this thread to moderator Post Follow-up to this message
Old Post
Gordon Sande
11-30-04 09:02 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:06 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.