Hi,
after some friendly requests and discussion, I'm planning to implement range checking as one of the next major things in GPC (probably in Januaray, if nothing urgent gets in between ...).
Note, I'm using "range checking" in the specific meaning I explained recently, not generally for all kinds of runtime checks, and not including overflow checking of arithmetic operations etc. (that will be a separate issue).
Also, as I said before, I'll do an "easy" implementation. I'm still not convinced that anything more is worth the (big) effort when the programmer in the rare (AFAICS) cases where it matters could just as well use explicit types etc. to avoid checks where he doesn't want them.
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
1. Help finding all places where range checking must be applied
In mean this from a Pascal point of view, covering, of course, all standards, dialects and extensions that GPC supports. So far I've found the following ones:
- assignment to variables and function results,
- value parameter passing to user-defined and built-in (e.g., `Chr', `FillChar', ...) routines,
- array indexing (R/W),
- array slice indexing (R/W),
- `for' loop bounds,
- conformant array range,
- actual schema discriminants,
- initialization of types, variables and typed constants,
- `asm' targets
2. Write test programs
Test programs should follow the guidelines in the manual. In particular, since most of the tests will check for errors, each one must be a separate test for each situation (each of the cases above plus any that others of you will come up with). For a way to test runtime errors see, e.g., fjf424d.pas.
Range checking will be on by default, and can be switched on/off with the options `--[no-]range-checking' and the compiler directives `{$[no-]range-checking}', and `{$R+}', `{$R-}'. A complete set of tests should also test all of those.
If you'd like to do so, please post a short note, so several of you won't duplicate efforts, but can coordinate.
Frank
Frank Heckenbach wrote:
after some friendly requests and discussion, I'm planning to implement range checking as one of the next major things in GPC
That would be great, as range checking is an important feature in any Pascal compiler.
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
- Help finding all places where range checking must be applied
Object and type extension ? Has --no-truncate-strings been implemented ?
- Write test programs
Count on me.
Regards,
Adriaan van Os
As an option I hope? Such as {$R+}, {$R-} like in TP/FP?
In some cases Range Checking would be good, but I like to program some low-level stuff, like emulators, and this would certainly get in my way sometimes.
after some friendly requests and discussion, I'm planning to implement range checking as one of the next major things in GPC
===== ======= Frank D. Engel, Jr.
Modify the equilibrium of the vertically-oriented particle decelerator to result in the reestablishment of its resistance to counterproductive atmospheric penetration.
__________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com
Frank D. Engel, Jr. wrote:
As an option I hope? Such as {$R+}, {$R-} like in TP/FP?
I think that's as far as we got in the previous discussions, but again: Yes, if there will ever be range checking, it will be optional (and on by default).
Frank
Adriaan van Os wrote:
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
- Help finding all places where range checking must be applied
Object and type extension ?
What do you mean precisely?
Has --no-truncate-strings been implemented ?
Not really (only in some special cases, such as constant initializers).
- Write test programs
Count on me.
Looking forward to it ...
Frank
<sorry for the private post>
Frank Heckenbach wrote:
Adriaan van Os wrote:
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
- Help finding all places where range checking must be applied
Object and type extension ?
What do you mean precisely?
I refer to a message of novermber 29, 2002
So, if we have two variables:
VAR V0: Enum0; V1: Emum1;
the rules of compatibilty would allow the assignment
V0:=V1
but the compiler would have to do a (optional) range check to be sure that a actual value of V1 is within the range of Enum0 ?
Exactly. Just the same as when Enum1 was declared first, and then Enum0 as a subrange of Enum1.
- Write test programs
Count on me.
Looking forward to it ...
What is the time frame ? Do you need the tests before, during or after implementing range checking in the compiler ?
Regards,
Adriaan van Os
I would be interested in helping too, but leaving for a week just this starurday. When i'll come back, and if it's still usefull, i'll be able to write test, especially for - for loops - array indexing - strings maybe ?
And in my dream, i'd like to help coding this, but i'd need time to understand the gpc internals (i know it's gcc front-end and already printed "Writing a compiler Front End", but i had no time until now... ).
What is the time frame ? Do you need the tests before, during or after implementing range checking in the compiler ?
Interested too in these informations :-)
Francois Schoubben wrote:
I would be interested in helping too, but leaving for a week just this starurday. When i'll come back, and if it's still usefull, i'll be able to write test, especially for
- for loops
- array indexing
- strings maybe ?
I will be pleased if you write the tests, as I am actually quite busy with the OS X port (not to mention other work).
And in my dream, i'd like to help coding this, but i'd need time to understand the gpc internals (i know it's gcc front-end and already printed "Writing a compiler Front End", but i had no time until now... ).
I guess Frank (Heckenbach) will appreciate any help (after you had time to understand gpc internals).
What is the time frame ? Do you need the tests before, during or after implementing range checking in the compiler ?
Interested too in these informations :-)
Francois Schoubben (Bureau 324-Tel:32/81/72.4989) FUNDP - Institut d'Informatique - Assistant 21 rue Grandgagnage, B-5000 Namur (Belgium)
Regards,
Adriaan van Os
Francois Schoubben wrote:
I would be interested in helping too, but leaving for a week just this starurday. When i'll come back, and if it's still usefull, i'll be able to write test, especially for
- for loops
- array indexing
- strings maybe ?
Yes, also strings (as a special casee of arrays, but one that should be checked separately). And at least all the cases I mentioned in my mail of 2002-12-14 (plus any others you may think of). I'd expect some 30-40 tests (each of which would be rather short), testing for positive and negative cases, command-line switches and compiler directives.
And in my dream, i'd like to help coding this, but i'd need time to understand the gpc internals (i know it's gcc front-end and already printed "Writing a compiler Front End", but i had no time until now... ).
I'd appreciate any such help (and if you won't make it for range checking, there are always enough issues to work on, that's not the problem ;-).
What is the time frame ? Do you need the tests before, during or after implementing range checking in the compiler ?
Interested too in these informations :-)
I'd like to have the tests before I start implementing it, (a) because I can then test my achievements anytime and (b) tests tend to be more objective when written in advance. (This doesn't mean that I won't write more tests while I implement it to cover special cases I might discover, but that should be the exception.)
Frank
I would be interested in helping too, but leaving for a week just
this
starurday. When i'll come back, and if it's still usefull, i'll be
able
to write test, especially for
- for loops
- array indexing
- strings maybe ?
Yes, also strings (as a special casee of arrays, but one that should be checked separately). And at least all the cases I mentioned in my mail of 2002-12-14 (plus any others you may think of). I'd expect some 30-40 tests (each of which would be rather short), testing for positive and negative cases, command-line switches and compiler directives.
Ok, i'll do that in two weeks (i'll just need time to read my mails :) ). I'll check the way other tests are done before starting.
I'd appreciate any such help (and if you won't make it for range checking, there are always enough issues to work on, that's not the problem ;-).
I guess yes :)
Adriaan van Os wrote:
Frank Heckenbach wrote:
Adriaan van Os wrote:
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
- Help finding all places where range checking must be applied
Object and type extension ?
What do you mean precisely?
I refer to a message of novermber 29, 2002
So, if we have two variables:
VAR V0: Enum0; V1: Emum1;
the rules of compatibilty would allow the assignment
V0:=V1
but the compiler would have to do a (optional) range check to be sure that a actual value of V1 is within the range of Enum0 ?
Exactly. Just the same as when Enum1 was declared first, and then Enum0 as a subrange of Enum1.
Oh, you mean the enum type extensions. I haven't implemented them, and I'm not sure if I ever will, so we can ignore them for now ...
Frank
Hi,
I'd like to know, if the way i do my tests is the right way...
I'v attached 8 basic tests (targzipped). Can anybody used to do testing in gnu pascal say me if i'm in the "dark side of the force" or not? I've read the 10.6 section in the manual and used the fjf424d.pas test as reference.
Beside that, do you know any resources speeking about (general) range check somewhere?
I have problems with seeing all the cases and with some "words" i think...
- array slice indexing (R/W),
? have i understood? (tests 07 and 08)
- conformant array range,
? is this for dynamic array sizes?
- 'asm' targets
? Never played with that, but it's the right time to start :-)
I'm on the doc for the others :)
On Fri, Feb 28, 2003 at 02:36:15PM +0100, Francois Schoubben wrote:
Hi,
I'd like to know, if the way i do my tests is the right way...
I'v attached 8 basic tests (targzipped). Can anybody used to do testing in gnu pascal say me if i'm in the "dark side of the force" or not? I've read the 10.6 section in the manual and used the fjf424d.pas test as reference.
Beside that, do you know any resources speeking about (general) range check somewhere?
I have problems with seeing all the cases and with some "words" i think...
- array slice indexing (R/W),
? have i understood? (tests 07 and 08)
Apparently not, see below.
- conformant array range,
? is this for dynamic array sizes?
A dummy but illustrative example:
program Foo (Output);
procedure P (I: Integer; A: array [L .. U: Integer] of Integer); { this is a conformant array ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } begin WriteLn (L, U, A[I]) end;
var V: array [1 .. 100] of Integer;
begin P (56, V[23 .. 89]) { this ^^^^^^^^^^ is an array slice } end.
Emil Jerabek
Francois Schoubben wrote:
I'd like to know, if the way i do my tests is the right way...
Genrally yes.
fsc04 and fsc05 are not range-check issues. String truncation is a separate topic which I won't be dealing with now. String range-checking occurs with `StringVar[Index]'.
Also fsc06 is another issue (I might fix this soon, but it's not range-checking). However, it will be a compile-time error then (modifying `for' loop counter), so the test must look a little different then.
Actually, fsc07 and fsc08 are (generally) accessing *outside* the array mem space (since the outer dimension is farther apart in memory), but, of course, just as well a case of range-error as `i := 1; j := 4' would be.
Emil Jerabek wrote:
- conformant array range,
? is this for dynamic array sizes?
A dummy but illustrative example:
program Foo (Output);
procedure P (I: Integer; A: array [L .. U: Integer] of Integer); { this is a conformant array ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } begin WriteLn (L, U, A[I]) end;
var V: array [1 .. 100] of Integer;
begin P (56, V[23 .. 89]) { this ^^^^^^^^^^ is an array slice } end.
Actually, I just noted, for conformant arrays, there can be two kinds of range-errors: Within the procedure, accessing outside of the actual range (here: L .. U); and when calling the procedure, passing a wrong array (this would be relevant if L .. U were of some subrange type in the procedure, and the actual array bounds do not fit into this subrange).
Frank
I did some more test and removed the bad one.
I put them here : http://www.info.fundp.ac.be/~fsc/dvpt/ zipped there http://www.info.fundp.ac.be/~fsc/dvpt/fsc.zip
I didn't changed 1 to 3.
Am i on the right way :) I know, i still have to play with conformant array and array slices... I'm working on.
I'd like to ask some question now...
Does packed array need separate tests? Does array in records need separate tests? Is setlength, concat, move, ... a kind of range check? (i don't think so) Is tests for "while true do i:=i+1" a kind of range check? (i don't think so) What does Frank meen by "'for' loop bounds ? Where can i find documentation for what's not in the manual? For exemple : frameAdress? index? insert? name? only? operator? qualified? readstr? result? trim? (maybe one or another is obvious and i missed it because of too obviousness :) )
If you give me a definition with as much as possible (Synopsis, Description, conforming to _example_ See also if possible), i'll put it in the manual format... It may help others...
Francois
Francois Schoubben wrote:
I'd like to ask some question now...
Does packed array need separate tests?
Better yes.
Does array in records need separate tests?
Probably not (but can't hurt to have one).
Is setlength, concat, move, ... a kind of range check? (i don't think so)
Concat, Move, no. SetLength could be considered a case for range-checking (conceptually, if we imagine the implicit `Length' field of a string to be of type `0 .. Capacity' rather than `Integer'); I tend to do so.
Is tests for "while true do i:=i+1" a kind of range check? (i don't think so)
Well, if i is declared as, say `var i: 1 .. 10 value 1', then indeed this loop should cause a range error the 10th time. But it's the same error as just `i := 10; i := i + 1', so the loop is irrelevant.
What does Frank meen by "'for' loop bounds ? Where can i find documentation for what's not in the manual? For exemple
For those that come from EP, BP etc., in the respective standard or documentation ...
frameAdress? index? insert? name? only? operator? qualified? readstr? result? trim? (maybe one or another is obvious and i missed it because of too obviousness :) )
None of these should require range checking, except `ReadStr' (read from a string like `Read' does from a text file) when reading an integer subrange.
If you give me a definition with as much as possible (Synopsis, Description, conforming to _example_ See also if possible), i'll put it in the manual format... It may help others...
`Conforming to' for all built-ins will be in the manual in the next version.
For the rest, I don't have the time, sorry. Unfortunately, writing the stuff (in particular the examples, and a good description) is what takes most time, not converting it to Texinfo ...
Frank