[fpc-devel]adhoc string bugs in 1.0.6 pre2 (not sure though)

beatlesnap at go.to beatlesnap at go.to
Wed Apr 17 13:45:23 CEST 2002


Hi, I've made a little study of errors related to strings, and specially with 
string length. There's an attach with all the examples cited below for you not 
to copy-paste the examples again.

I'm sorry if

attachments are not permitted in this list.
I should use the bug webpage instead.

I think that I'm doing right sending the bugs here, they're related and string 
is an important thing I think.

adrian15.

Here goes the bugs (some of them may not be bugs, sorry then):

Hi, I want to comment some bugs or perhaps misconceptions on 1.0.6 snapshot for 
DosGo32v2.
I download them 17 April 2002.

This program (test1.pas) generates an error when compiling:


program myprogram;

const

mynumber=30000000000000;

var

mystring : string[300*mynumber];

begin
write('Hello world');

end.


Error for test1.pas when compiling is the following:

test1.pas(9,31) Error: Illegal expression
test1.pas(9,31) Error: string length must be a value from 1 to 255
test1.pas(15) Fatal: There were 2 errors compiling module, stopping

What I find erroneous is: "value from 1 to 255" because I think that a string 
length now can be more than 255 isn't it?

This program (test2.pas) doesn't generate an error when compiling:

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];

begin
write('Hello world');

end.

So I suppose that strings over 255 are allowed.

This program (test3.pas) tried to see the length of the string, I don't know 
how to do it.
Please just change the line to see the string length and tell us the errors if 
there are any.

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];

begin
write('Hello world');
write('Length of string is: ',mystring.length());
end.


This program (test4.pas) 
its_the_access_to_array_position_shouldnt_be_processed_as_an_index_out_of_array_
error
shows an error (I don't remember which) but the thing is that it doesn't show 
the error 
as a "fatal string exceeds line" but I think there was a runtime error. Oh 
shit, I don't remember.

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];
myvarnumber : longint;

begin
myvarnumber:=3000000*mynumber;


writeln('Hello world');
writeln('Is it perhaps the myvarnumber alone: ',myvarnumber);
writeln('It is the access to the string', mystring[myvarnumber]);

end.

Note after another compiling comenting the third writeln line I determined that 
the error was given because of this third writeln line, e.g., acceding to 
mystring[myvarnumber]

This program (test5.pas) comes to show that test4.pas isn't right because here 
the problem is treated in another way: The error is "fatal string exceeds line".

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];
myvarnumber : longint;

begin
myvarnumber:=3000000*mynumber;


writeln('Hello world');
writeln('Is it perhaps the myvarnumber alone: ',myvarnumber);
writeln('what happens if we put
        the number itself: ', mystring[410065408]);

end.


This program (test6.pas) causes a runtime error 216. Shouldn't be treated as a 
index out of 
string length error or similar?

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];
myvarnumber : longint;

begin
myvarnumber:=3000000*mynumber;


writeln('Hello world');
writeln('Position', myvarnumber, 'of the string is: ',mystring[myvarnumber]);


end.

This program (test7.pas) I suppose that works in 1.0.4 version. But I'm sure 
that doesn't work in this version.

Is it right because of Delphi compatibility or not?

program myprogram;

const

mynumber=3000;

var

mystring : string[300*mynumber];

begin
write('Hello world');
write('Length of string is: ',length(mystring);
end.



That's all. I have no time I think you should try similar examples but trying 
with arrays instead of string. In my examples you could change 
mystring : string[300*mynumber]; line and put:

mystring: array [1..300*mynumber] of integer;

and see what happens. I have no time for doing it.

My conclusion is that you have some problem when processing expressions that 
results in a number instead than a number itself that points to an array 
position. (index instead of position is a better word perhaps?)

That's to say test4.pas and test4.pas do the same thing but the error is 
processed in another way.

Perhaps this ad-hoc made errors are errors that should happen usually but... I 
have the hope that some of them are real errors and that this message isn't 
wasting your time.

See you,

adrian15.

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: string_evaluation_errors_1_0_6_pre_2.zip
Type: application/x-zip-compressed
Size: 3187 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20020417/f0482dce/attachment.bin>


More information about the fpc-devel mailing list