'operator not' with bitpacked boolean
Original Reporter info from Mantis: UK
-
Reporter name: UK
Original Reporter info from Mantis: UK
- Reporter name: UK
Description:
The 'operator not' evaluates more than a single bit if the operand is a field of bitpacked record.
variant.inc:
operator :=(const source : boolean) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
Variantmanager.varfromBool(Dest,Source);
end;
operator not(const op : variant) dest : variant;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
dest:=op;
variantmanager.varnot(dest);
end;
variant.pp:
procedure sysvarfrombool (var Dest : Variant; const Source : Boolean);
begin
DoVarClearIfComplex(TVarData(Dest));
with TVarData(Dest) do begin
vType := varBoolean;
vBoolean := Source;
end;
end;
procedure sysvarnot(var v: Variant);
..
varBoolean: begin
vBoolean := not PWordBool(vPointer)^;
vType := varBoolean;
end;
Steps to reproduce:
program test;
type
TData = bitpacked record
a,b: boolean;
end;
var
data: TData;
x : boolean;
begin
with data do begin
for x:=false to true do begin
a := x;
b := not x;
writeln( 'a = ', a:5, ' not a = ', not a );
writeln( 'b = ', b:5, ' not b = ', not b );
writeln;
end;
end;
end.
Mantis conversion info:
- Mantis ID: 33780
- OS: windows, linux
- Platform: i386, x86_64
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 33906 (#49f63d67)