Do not use bit and for conjunction of predicates (PR c/81272).

Message ID 7aea6151-d206-209f-a6ab-0a27f45ea914@suse.cz
State New
Headers show
Series
  • Do not use bit and for conjunction of predicates (PR c/81272).
Related show

Commit Message

Martin Liška Feb. 19, 2018, 1:43 p.m.
Hi.

This changes code to be consistent:

      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
...
	 else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1;

That's fixed in the patch.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin


libdecnumber/ChangeLog:

2018-02-19  Martin Liska  <mliska@suse.cz>

	PR c/81272
	* decNumber.c (decCompareOp): Do not use bit and
	for conjunction of predicates.
---
 libdecnumber/decNumber.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jeff Law Feb. 19, 2018, 4:45 p.m. | #1
On 02/19/2018 06:43 AM, Martin Liška wrote:
> Hi.

> 

> This changes code to be consistent:

> 

>       if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {

> ...

> 	 else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1;

> 

> That's fixed in the patch.

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

> 

> Ready to be installed?

> Martin

> 

> 

> libdecnumber/ChangeLog:

> 

> 2018-02-19  Martin Liska  <mliska@suse.cz>

> 

> 	PR c/81272

> 	* decNumber.c (decCompareOp): Do not use bit and

> 	for conjunction of predicates.

OK

jeff

Patch

diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index ebfb6c5dd96..e4194211fdc 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -6029,11 +6029,11 @@  decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
 
     /* If total ordering then handle differing signs 'up front' */
     if (op==COMPTOTAL) {		/* total ordering */
-      if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {
+      if (decNumberIsNegative(lhs) && !decNumberIsNegative(rhs)) {
 	result=-1;
 	break;
 	}
-      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
+      if (!decNumberIsNegative(lhs) && decNumberIsNegative(rhs)) {
 	result=+1;
 	break;
 	}