Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Mirsad Todorovac
Subject: range check test programs
Date: 29 Jul 2003, 19:38:50
On Sat, 12 Jul 2003, Frank Heckenbach wrote:
[...]
> Perhaps you've missed Francois' previous mail where he quoted the
> items I have thought of already (appended below). If you can think
> of more (which Francois didn't already write), fine, but first we
> need someone to write those tests.
Sure.
Here is the point when I think I've done what I could. Let's go step by
step with this list (I'm sorry if I'm repepating something that has been
said already, but the list archive appears to be out :-(:
> > > What's missing is a test where the formal discriminants are of a
> > > subrange type and the actual discriminants (in `New' or a variable
> > > declaration) are out of range.
TEST mir040a.pas: gpc1: warnings being treated as errors
./mir040a.pas: In main program:
./mir040a.pas:34: warning: tag value must be a constant of ordinal type
failed (I think it could be the problem in GPC, since the code is precisely
the same, as with integer subrange bounds conformant arrays.)
Am I allowed to suppress this specific warning, is it possible
to do suppress it, or have I done something wrong?
(mir040a.pas is in attachment.)
> > > Initialization of types, variables and typed constants. (I.e.,
> > > variables (or fields) or subrange type with an out-of-range
> > > initializer; must be locally, otherwise GPC won't accept
> > > non-constants initializers.)
Done. mir041[ceil][ul].pas
> > > The `FillChar' test (fsc20.pas) shouldn't (I think) work like this
> > > since it takes an untyped parameter. (Some people (ab)use it for
> > > strange purposes.) Instead, the 3rd parameter may also be an
> > > integer, so it's an error if it's < 0 or > Ord (MaxChar).
Done: mir042[ul].pas
> > I've found some more missing cases:
> >
> > - `Return' (where the result type is a subrange and the `Return'
> > value is out of range)
Done. mir0{24c[ul],25[ei][ul],26l[ul].pas
> > - `Pack', `Unpack' (the index parameter)
Done. mir03[56]*.pas
> > - `Include', `Exclude'
Done. mir028*.pas
> > - `Inc', `Dec'
Done. mir027*.pas
> > - 4th parameter of `BlockRead', `BlockWrite' (not obvious, but GPC
> > allows a subrange here which may be too small for the actual
> > result)
Done. mir039*.pas
> > - `Val' (2nd and 3rd parameter)
Done 2nd parm. mir034[ab].pas
Q: What is the legal range for 3rd parm of Val?
> > - `and', `or', `xor', `shl', `shr' used as procedures, e.g., if a is
> > of type 1 .. 10: a := 5; or (a, 8) (whereas normal use as
> > operators will be covered by assignments or whatever is done with
> > them)
Done. mir03[0-3]*.pas
> > - Conformant arrays (i.e., where the index type in the conformant
> > array in the formal parameter list is a subrange, and the actual
> > parameter's range is too big -- check both bounds)
Integer subrange Done. Problems with Char and enumerated subranges.
I can confirm that it gives me this error:
TEST mir038ea.pas: ./mir038ea.pas: In main program:
./mir038ea.pas:29: invalid operands to binary `+'
./mir038ea.pas:29: incompatible type for argument 1 of `conformantArray'
./mir038ea.pas:11: routine declaration
failed
{$gnu-pascal}
program mir038ea;
{slice array write, what Francois has done for Integer here is for subrange}
uses GPC;
type TGrayScale = (Black, Gray10, Gray20, Gray30, Gray40, Gray50,
Gray60, Gray70, Gray80, Gray90, White);
TMidTones = Gray30..Gray70;
var v : array[1..100] of Integer;
i,j : TGrayScale;
procedure conformantArray(a: array[l..u : TMidTones] of Integer);
begin
end;
procedure ExpectError;
begin
if ExitCode = 0 then
WriteLn ('failed')
else
begin
WriteLn ('OK');
Halt (0) {!}
end
end;
begin
AtExit(ExpectError);
i:=Gray30; j:=White;
{j > upper}
conformantArray(v[i..j]);
end.
> > - `New' with variant records (where the variant tag is of subrange
> > type)
See the generated warning in test above.
> > - sets (e.g., assigning a set of a larger range to one of a smaller
> > range where the former contains out of range elements)
Done. mir029*.pas
Conclusion:
1. variant record warning
2. Val's 3rd parameter
3. Possible bug with conformant arrays when bounds are of Char subrange,
confirmed it occurs with enumerated subranges too
4. All tests WILL AND MUST give "failed" if you don't have range-checking
compiler, with range-checking on, they should give OK
The latest result is at
http://www.alu.hr/~mtodorov/pascal/rngv0.03.tar.gz
There is significantly more of them now than in v0.02, and some bugs are
fixed.
I think we're moving somewhere.
Have a nice day,
Mirsad
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
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).