-----Original Message----- From: gpc-owner@gnu.de [mailto:gpc-owner@gnu.de]On Behalf Of Maurice Lombardi Sent: 16 January 2002 10:47 To: gpc@gnu.de Subject: Re: Is this a bug or me being stupid?
Martin G C Davies wrote:
main: sizeof curpseudoreg=2 main: alignof curpseudoreg=2 main: curpseudoreg initially set to 5 initregcons: sizeof curpseudoreg=4 initregcons: alignof curpseudoreg=4 initregcons: curpseudoreg=327680 initregcons: curpseudoreg now set to 99 main: curpseudoreg=0
So the quuestion is, why is the sizeof and alignog different in the two modules?
They are not the same variable. You see that the values also of curpseudoreg are different.
Thanks for the analysis Maurice but I don't think it's correct for three reasons:-
1. If I change packed -32768..32767 to integer(16) the problem goes away for the example given.
2. I added a writlen of the addr of curpseudoreg and it is the same address in each module (new code below).
3. 327680 is hex 50000 so it just looks like the sizeof and alignof of 4 are what is mucking it up.
Thus I still think this a gpc bug.
main.pas ========
program main(output) ;
procedure initregcons ; external ;
var curpseudoreg : packed -32768..32767number ; external ;
begin writeln( 'main: addr curpseudoreg=' , integer( addr( curpseudoreg ) ) ) ; writeln( 'main: sizeof curpseudoreg=' , sizeof( curpseudoreg ) ) ; writeln( 'main: alignof curpseudoreg=' , alignof( curpseudoreg ) ) ; curpseudoreg := 5 ; writeln( 'main: curpseudoreg initially set to ' , curpseudoreg ) ; initregcons ; writeln( 'main: curpseudoreg=' , curpseudoreg ) ; end.
regabs.pas ==========
module regabs ;
var curpseudoreg : packed -32768..32767 ; external ; var curpseudoreg : packed -32768..32767 ;
procedure initregcons ; external ;
procedure initregcons ; begin writeln( 'initregcons: addr curpseudoreg=' , integer( addr( curpseudoreg ) ) ) ; writeln( 'initregcons: sizeof curpseudoreg=' , sizeof( curpseudoreg ) ) ; writeln( 'initregcons: alignof curpseudoreg=' , alignof( curpseudoreg ) ) ; writeln( 'initregcons: curpseudoreg=' , curpseudoreg ) ; curpseudoreg := 99 ; writeln( 'initregcons: curpseudoreg now set to ' , curpseudoreg ) ; end ;
end.
and the output when run is:-
main: addr curpseudoreg=522892 main: sizeof curpseudoreg=2 main: alignof curpseudoreg=2 main: curpseudoreg initially set to 5 initregcons: addr curpseudoreg=522892 initregcons: sizeof curpseudoreg=4 initregcons: alignof curpseudoreg=4 initregcons: curpseudoreg=327680 initregcons: curpseudoreg now set to 99 main: curpseudoreg=0