[fpc-devel] Extended($FFFFFFFFFFFFFFFF) = -1?

Ewald ewald at yellowcouch.org
Fri Feb 28 20:21:33 CET 2014


Hi,

Consider the following program (compiled using revision 26807 on OSX):

=======
Program QWordToExtended;

Begin
	WriteLn(Sizeof(Extended));
	WriteLn(Sizeof(QWord));
	WriteLn(Sizeof(Longword));

	WriteLn(Extended(QWord($FFFFFFFFFFFFFFFF)));	//1
	WriteLn(Extended($FFFFFFFFFFFFFFFF));			//2
	
	WriteLn(Extended(Longword($FFFFFFFF)));			//3
	WriteLn(Extended($FFFFFFFF));					//4
End.
=======

Here I would expect four rather large values on standard output. The thing is that the second test gives me -1. I suspect this is due to the compiler interpreting the constant as an Int64; this is confirmed by the first test. Since I was curious as to the intended-ness of this behaviour I wrote the second set of tests which show me that this is not true for longwords: both 3 & 4 give the same result. This lead me to the conclusion that this is a bug. Shall I file it?

Some important note, I think: the first sizeof's of the example return 10, 8, 4 on this machine.

--
Ewald

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140228/99372dc0/attachment.html>


More information about the fpc-devel mailing list