Sign in Join

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

Mailing lists / fpc-devel / 2003-10

Freepascal bug?

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Tamas Konkoly

Hi,

I found a problem in fpc. I don't know that this is a bug or not. I would like to know why don't work the first d declaration. The second declaration work only well, because I checked it.

type TR=record
       a,b,c:longint;
     end;
var data:array[0..100]of TR;
procedure pp(var r:TR);
var d:^TR;
begin
; // << this is not compileable
(TR); // << this is compileable
end;
begin
pp(data[0]);
end.

Tcc

Reply by email

Unknown author
to Tamas Konkoly
Tamas Konkoly wrote 15 lines
Hi, I found a problem in fpc. I don't know that this is a bug or not. I would like to know why don't work the first d declaration. The second declaration work only well, because I checked it. type TR=record a,b,c:longint; end; var data:array[0..100]of TR; procedure pp(var r:TR); var d:^TR; begin ; // << this is not compileable

Of course not, it's wrong. r is not an array.

Michael.

Reply by email

Balogh, Karoly (Charlie/iNQ
to Tamas Konkoly: I found a problem in fpc. I don't know that this is a bug or not. I would like to know…

Hi,

Tamas Konkoly wrote 17 lines
I would like to know why don't work the first d declaration. The second declaration work only well, because I checked it. type TR=record a,b,c:longint; end; var data:array[0..100]of TR; procedure pp(var r:TR); var d:^TR; begin ; // << this is not compileable (TR); // << this is compileable end; begin pp(data[0]); end.

This code is buggy, and shows bad coding too, IMO. The problem is that r is not an array. The easiest way to fix is some typecasts.

type PTR = ^TR;
d:=@(PTR(@r)[20]); // ugly;

IMO, the above code should look like this:

type PTR=^TTR;
     TTR=record
       a,b,c:longint;
     end;
var data:array[0..100] of TTR;
procedure pp(r:PTR);
var d:PTR;
begin
 ;
end;
begin
pp(@data[0]);
end.

Hope this helps.
You can ask me in private mail in hungarian if needed.

Bye,

Charlie/iNQ (SceneCON - http://scenecon.intro.hu) .:%[ Cybernetic Hydraulic Android Responsible for ]%:. .:%[ Logical Infiltration and Exploration ]%:. .:%[ Member of TeamOS/2 Hungary ]%:. .:%[ Member of Hungarian Amiga User Group ]%:.

Reply by email