From 57008babd87cdb1c878a59051deb9a9357ebffa8 Mon Sep 17 00:00:00 2001 From: "Igor V. Kovalenko" Date: Mon, 30 Jan 2023 23:16:04 +0300 Subject: [PATCH] Fix arithmetic conversion from larger unsigned operand type Fixes: 16944a0de7 ("Arithmetic conversions for unary and binary expressions, bug 231859.") Closes: https://github.com/eclipse-cdt/cdt/issues/265 --- .../cdt/internal/core/dom/parser/ArithmeticConversion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java index ce8d9a32141..dbc2c9dc718 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java @@ -201,8 +201,8 @@ public abstract class ArithmeticConversion { return unsignedType; } - // The signed has the higher rank. - if (signedRank.ordinal() > unsignedRank.ordinal()) { + // The signed has the higher rank, check if signed type can represent all unsigned values + if (fitsIntoType(signedType, unsignedType)) { return signedType; }