View Issue Details

IDProjectCategoryView StatusLast Update
0035272FPCCompilerpublic2019-06-02 22:04
ReporternanobitAssigned ToJonas Maebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformwin32OSWindowsOS Version10
Product Version3.0.4Product Build 
Target VersionFixed in Version3.3.1 
Summary0035272: longbool xor
DescriptionBoolean operations on longbools should operate logically (non-bitwise).
But xor returns the bitwise xor which can be the negation of the correct result.

var b1, b2, b3: longbool;
b1 := longbool(1); b2 := longbool(2);
b3 := b1 or b2; // gives -1 (True); would be 3 if bitwise
b3 := b1 and b2; // gives -1 (True); would be 0 (False) if bitwise
b3 := not b2; // gives 0 (False); would be -3 (True) if bitwise
b3 := b1 xor b2; // gives 3 (bitwise): dword(b3) := dword(b1) xor dword(b2);
b3 := boolean(b1) xor boolean(b2); // correctly gives 0 (False)

(b1 xor b2) returns True (this says: inputs are different),
xor fails to see that both inputs are logical equal (True, True)
(b1 and b2) correctly says, they are logical equal (True, True).
TagsNo tags attached.
Fixed in Revision42167
FPCOldBugId
FPCTarget-
Attached Files

Activities

nanobit

2019-03-25 14:31

reporter   ~0115040

Don't get confused by the verbosity of the test,
I really mean only the xor operator is buggy:)
Gives wrong result if the True ordinalities are different.

Jonas Maebe

2019-06-02 22:04

manager   ~0116539

"and" was similarly broken if full boolean evaluation was enabled.

Issue History

Date Modified Username Field Change
2019-03-25 12:03 nanobit New Issue
2019-03-25 14:31 nanobit Note Added: 0115040
2019-06-02 22:04 Jonas Maebe Assigned To => Jonas Maebe
2019-06-02 22:04 Jonas Maebe Status new => resolved
2019-06-02 22:04 Jonas Maebe Resolution open => fixed
2019-06-02 22:04 Jonas Maebe Fixed in Version => 3.3.1
2019-06-02 22:04 Jonas Maebe Fixed in Revision => 42167
2019-06-02 22:04 Jonas Maebe FPCTarget => -
2019-06-02 22:04 Jonas Maebe Note Added: 0116539