Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-06

A bug

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello,

Sorry for not reporting this bug in an ordinary way - I just don't have a web access right now.

Just wanted to show you code that bugs in v1.1.

--------
type
        TCl = class
                public
                        a: AnsiString;
                        procedure load;
                end;
procedure TCl.load;
        procedure adddata (var buffer; l: dword);
        begin
                setlength (a, length (a) + l);
                move (buffer, (pointer (a) + length (a))^, l);
        end;
begin
        adddata (pointer(a)^,length (a));
end;
var
        Cl: TCl;
begin
        Cl := TCl.create;
cl.a:='34343';
cl.load;
cl.load;
writeln (cl.a);
end.
--------
  Seems to be that in "adddata" variable "a" is handled somehow
  incorrectly or something...
  There is also an inline problem in v1.1. That was for some time
  solved and now it appered again.

Best regards,
Aleksey

Reply by email

Peter Vreman
to Aleksey V. Vaneev
you wrote 6 lines
Hello, Sorry for not reporting this bug in an ordinary way - I just don't have a web access right now. Just wanted to show you code that bugs in v1.1.

It's better to report bugs for 1.1 in this mailinglist. The web bug repository is more for the distributed versions.

Peter

Reply by email

Peter Vreman
to Aleksey V. Vaneev: Sorry for not reporting this bug in an ordinary way - I just don't have a web access…
Show quoted text 35 lines
type TCl = class public a: AnsiString; procedure load; end; procedure TCl.load; procedure adddata (var buffer; l: dword); begin setlength (a, length (a) + l); move (buffer, (pointer (a) + length (a))^, l); end; begin adddata (pointer(a)^,length (a)); end; var Cl: TCl; begin Cl := TCl.create; cl.a:='34343'; cl.load; cl.load; writeln (cl.a); end. -------- Seems to be that in "adddata" variable "a" is handled somehow incorrectly or something...

This is not a bug in the compiler or RTL. Your code is wrong because it assumes that the setlength doesn't change the pointer of an ansistring which is not true. When setlength requires more space it can be necessary to allocate a new memory block elsewhere in the memory.

There is also an inline problem in v1.1. That was for some time solved and now it appered again.

Which bug ?

Peter

Reply by email

Aleksey V. Vaneev

Hello,

> There is also an inline problem in v1.1. That was for some time > solved and now it appered again. Which bug ?

I've sent HRC unit here. It doesn't works again... But when I remove all "inline" directives it works.

Best regards,
Aleksey

Reply by email