GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
Diese Seite auf deutsch

Mail #12387

Back to main page of archive

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  

From: Peter N Lewis
Subject: range checking
Date: 9 Jul 2005, 09:53:41

Ok, I've got my application compiling and linking (all 250+ units).

Now I'm trying to test it out.  Currently it is crashing out with 
range checks.  The first was one I'm used to with GPC, passing an 
SInt32 to a UInt32 (often these types are used interchangeably by the 
system to refer to a generic block of four bytes (eg random number 
seed) and so ensuring they match is not normally that important, but 
GPC range checks on these.  I've written SafeCast functions for 
Signed to Unsigned and vice versa.  I guess I'll eventually catch 
them all.

The next one is more challenging, since I don't see a good workaround.

s: String(255)

@s[1] range checks if Length(s) is 0.

While this might technically be correct (the subscript is out of 
bounds), the actual address is valid.

This is quite challenging to work around, since I'm often forced to 
deal with strings as a pointer to chars and a length, and this means 
that code to say draw a string like:

DrawString( @s[1], Length(s) );

now needs to special case for s = ''.

I would contend that in the case of @s[x], x should be checked 
against a range of 1..Length(x)+1 because it should be legal to point 
to the next free character.  Whether this is reasonably doable or 
not, I don't know.

If s were short strings, I could work around it with pointer 
arithmetic (@s+1), but given it is a Schema, I don't know how I would 
safely get the address of the first character of the string in the 
case where s might be empty.

More precise control over range checking ,might be helpful, options 
to disable range checking for strings, or perhaps limit them to 
capacity range checking, as well as disabling range checking on casts 
would be nice to get things going (I prefer to run with as much 
protection as possible generally, but sometimes range checking can be 
overly enthusiastic).
    Peter.

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  


Replies

Author Subject Date
Frank Heckenbach range checking 9 Jul 2005, 04:08:50
Gale Paeper range checking 9 Jul 2005, 21:36:05

Back to main page of archive


Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.

Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.


This page was created by Crystal 0.999 (Linux 2.4.27/i686).