Re: QC Report on Swap Function



At 18:51:52, 28.08.2005, Dennis wrote:

> Hi
>
> Do you find it OK that this report is closed with status "As designed"?
>
> swap is defective on 4 byte variables
> http://qc.borland.com/wc/qcmain.aspx?d=13719

I don't see it as defective.

Swap is a very old function, carried over from 16 bit Turbo Pascal, and
it was never intended to do anything more than swap two bytes (and AFAIK,
that is how it is documented), so yes, I think it is OK that it doesn't
touch anything else but these two bytes, and does not affect the top word
of a 32 bit type.

>From the D7 help files:

<<
Category
backward compatibility routines

Delphi syntax:
function Swap(X);

Description
In Delphi code, Swap exchanges the high-order bytes with the low-order
bytes of the argument. X is an expression of type SmallInt, as a 16-bit
value, or Word. This is provided for backward compatibility only.
>>

--
Rudy Velthuis [TeamB] http://velthuis.homepage.t-online.de

"Well-timed silence hath more eloquence than speech."
- Martin Fraquhar Tupper
.