fpc trunk issue with StreamIO or TMemoryStream

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

fpc trunk issue with StreamIO or TMemoryStream

Luca Olivetti-2
I'm facing a strange issue, I don't know if it's StreamIO or
TMemoryStream. The following program, compiled with fpc

Free Pascal Compiler version 3.2.0-beta [2019/04/26] for i386

(I checked trunk and I don't see changes in streams or streamio)

prints 3 lines but they are empty!

---
---
---

If I remove the "stream.position:=0", or I use $H- (or line:shortstring)
or I avoid the RStream procedure (i.e I put what it does in the main
program) or I use fpc 3.0.4 it correctly prints

--- a
--- b
--- c

Does it ring any bell?

The stream.position:=0 is really strange, since it just calls seeks
which in turn only sets FPosition to 0 (and it was already 0!).

In my project I'm actually using a TMemoryStream, but it has the same issue.

Here's the test program

program Project1;
{$mode objfpc}
{$H+}

uses Classes, SysUtils, StreamIO;


procedure RStream(s:TStream);
var f:textfile;
     line:string;
begin
   AssignStream(f,s);
   Reset(f);
   while not eof(f) do
   begin
     readln(f,line);
     writeln('--- ',line);
   end;
   Close(f);
end;

var
   stream: TStringStream;
begin
   stream:=TStringStream.Create('a'#13#10'b'#13#10'c'#13#10);
   stream.position:=0;
   RStream(stream);
   stream.free;
   readln;
end.






_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Michael Van Canneyt


On Mon, 7 Oct 2019, Luca Olivetti wrote:

> I'm facing a strange issue, I don't know if it's StreamIO or
> TMemoryStream. The following program, compiled with fpc
>
> Free Pascal Compiler version 3.2.0-beta [2019/04/26] for i386
>
> (I checked trunk and I don't see changes in streams or streamio)

I tested your program with trunk, and it works OK.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Luca Olivetti-2
El 7/10/19 a les 15:18, Michael Van Canneyt ha escrit:

>
>
> On Mon, 7 Oct 2019, Luca Olivetti wrote:
>
>> I'm facing a strange issue, I don't know if it's StreamIO or
>> TMemoryStream. The following program, compiled with fpc
>>
>> Free Pascal Compiler version 3.2.0-beta [2019/04/26] for i386
>>
>> (I checked trunk and I don't see changes in streams or streamio)
>
> I tested your program with trunk, and it works OK.

Thank you for testing, maybe it's time to upgrade the compiler.
Per chance, do you know what could possibly have changed to fix the issue?
I'm using svn revision 41937 and I had a quick look at the changes in
the repo, the only thing that caught my eyes is the ";overload;" added
to the Read/Write methods of THandleStream/TCustomMemoryString/TMemoryString

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Michael Van Canneyt


On Mon, 7 Oct 2019, Luca Olivetti wrote:

> El 7/10/19 a les 15:18, Michael Van Canneyt ha escrit:
>>
>>
>> On Mon, 7 Oct 2019, Luca Olivetti wrote:
>>
>>> I'm facing a strange issue, I don't know if it's StreamIO or
>>> TMemoryStream. The following program, compiled with fpc
>>>
>>> Free Pascal Compiler version 3.2.0-beta [2019/04/26] for i386
>>>
>>> (I checked trunk and I don't see changes in streams or streamio)
>>
>> I tested your program with trunk, and it works OK.
>
> Thank you for testing, maybe it's time to upgrade the compiler.
> Per chance, do you know what could possibly have changed to fix the issue?
> I'm using svn revision 41937 and I had a quick look at the changes in
> the repo, the only thing that caught my eyes is the ";overload;" added
> to the Read/Write methods of THandleStream/TCustomMemoryString/TMemoryString

Well, lots of things changed in trunk regarding stream handling (Delphi
comapatibility) but these things were not merged to 3.2, since they require
compiler changes, and these changes were also not merged to 3.2, since
they're quite invasive.

The 'overload' just means that the compiler will not stop searching in the
current class but will consider parent classes as well. This should not
change the behaviour in case the stream variable is declared as TSTream.
(as should be the case inside assignstream)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Luca Olivetti-2
El 7/10/19 a les 18:29, Michael Van Canneyt ha escrit:

>
>
> On Mon, 7 Oct 2019, Luca Olivetti wrote:
>
>> El 7/10/19 a les 15:18, Michael Van Canneyt ha escrit:
>>>
>>>
>>> On Mon, 7 Oct 2019, Luca Olivetti wrote:
>>>
>>>> I'm facing a strange issue, I don't know if it's StreamIO or
>>>> TMemoryStream. The following program, compiled with fpc
>>>>
>>>> Free Pascal Compiler version 3.2.0-beta [2019/04/26] for i386
>>>>
>>>> (I checked trunk and I don't see changes in streams or streamio)
>>>
>>> I tested your program with trunk, and it works OK.
>>
>> Thank you for testing, maybe it's time to upgrade the compiler.
>> Per chance, do you know what could possibly have changed to fix the
>> issue?
>> I'm using svn revision 41937 and I had a quick look at the changes in
>> the repo, the only thing that caught my eyes is the ";overload;" added
>> to the Read/Write methods of
>> THandleStream/TCustomMemoryString/TMemoryString
>
> Well, lots of things changed in trunk regarding stream handling (Delphi
> comapatibility) but these things were not merged to 3.2, since they require
> compiler changes, and these changes were also not merged to 3.2, since
> they're quite invasive.
>
> The 'overload' just means that the compiler will not stop searching in the
> current class but will consider parent classes as well. This should not
> change the behaviour in case the stream variable is declared as TSTream.
> (as should be the case inside assignstream)

My bad, I'm not on trunk, I'm on the fixes_3_2 branch :-(
Sorry for the confusion.
I checked out the latest version of that branch (I'm not confident
enough to use trunk in production) but it has the same problem.
Oh, well, I can use shortstrings in this application, though it really
puzzles me (setting position:=0 doesn't change anything yet it causes
this problem).

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Bart-48
On Mon, Oct 7, 2019 at 10:30 PM Luca Olivetti <[hidden email]> wrote:

> My bad, I'm not on trunk, I'm on the fixes_3_2 branch :-(
> Sorry for the confusion.
> I checked out the latest version of that branch (I'm not confident
> enough to use trunk in production) but it has the same problem.
> Oh, well, I can use shortstrings in this application, though it really
> puzzles me (setting position:=0 doesn't change anything yet it causes
> this problem).

It's a regression and needs to be fixed before 3.2.0 is released.
--
Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Michael Van Canneyt


On Mon, 7 Oct 2019, Bart wrote:

> On Mon, Oct 7, 2019 at 10:30 PM Luca Olivetti <[hidden email]> wrote:
>
>> My bad, I'm not on trunk, I'm on the fixes_3_2 branch :-(
>> Sorry for the confusion.
>> I checked out the latest version of that branch (I'm not confident
>> enough to use trunk in production) but it has the same problem.
>> Oh, well, I can use shortstrings in this application, though it really
>> puzzles me (setting position:=0 doesn't change anything yet it causes
>> this problem).
>
> It's a regression and needs to be fixed before 3.2.0 is released.

Please report a bug in the bugtracker, to make sure it is fixed.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc trunk issue with StreamIO or TMemoryStream

Luca Olivetti-2
El 8/10/19 a les 8:50, Michael Van Canneyt ha escrit:

>
>
> On Mon, 7 Oct 2019, Bart wrote:
>
>> On Mon, Oct 7, 2019 at 10:30 PM Luca Olivetti <[hidden email]> wrote:
>>
>>> My bad, I'm not on trunk, I'm on the fixes_3_2 branch :-(
>>> Sorry for the confusion.
>>> I checked out the latest version of that branch (I'm not confident
>>> enough to use trunk in production) but it has the same problem.
>>> Oh, well, I can use shortstrings in this application, though it really
>>> puzzles me (setting position:=0 doesn't change anything yet it causes
>>> this problem).
>>
>> It's a regression and needs to be fixed before 3.2.0 is released.
>
> Please report a bug in the bugtracker, to make sure it is fixed.

Done:
https://bugs.freepascal.org/view.php?id=36147

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal