wpp: Fix the output type for the "unsigned OP signed" cases in BIN_OP_INT and friends. (was: libs/wpp/ppy.y signedness fixes)

Gerald Pfeifer gerald at pfeifer.com
Sat Feb 12 17:54:05 CST 2011


On Wed, 23 Jul 2008, Alexandre Julliard wrote:
>> In ISO C, operations involving both signed and unsigned types are 
>> using signed.  If the case of ui = ui OP si is really ment to make
>> use of this (despite the result being stored in an unsigned type),
>> we'd need to handle this via two casts, but I doubt this is really
>> the intent here.
> It's supposed to follow the C rules, so yes the result most likely needs
> to be signed in this case. That doesn't mean using two casts, it means
> using the correct output type.

Yes, you're totally right.  Apologies for the delay in submitting
this patch that implements your request.

This should do the job.

Gerald


---
 libs/wpp/ppy.y |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libs/wpp/ppy.y b/libs/wpp/ppy.y
index 5a63494..5f1566e 100644
--- a/libs/wpp/ppy.y
+++ b/libs/wpp/ppy.y
@@ -61,7 +61,7 @@
 	else if(cv_signed(v1) && !cv_signed(v2))	\
 		r.val.si = v1.val.si OP v2.val.ui;	\
 	else if(!cv_signed(v1) && cv_signed(v2))	\
-		r.val.ui = v1.val.ui OP v2.val.si;	\
+		r.val.si = v1.val.ui OP v2.val.si;	\
 	else						\
 		r.val.ui = v1.val.ui OP v2.val.ui;
 
@@ -72,7 +72,7 @@
 	else if(cv_signed(v1) && !cv_signed(v2))	\
 		r.val.sl = v1.val.sl OP v2.val.ul;	\
 	else if(!cv_signed(v1) && cv_signed(v2))	\
-		r.val.ul = v1.val.ul OP v2.val.sl;	\
+		r.val.sl = v1.val.ul OP v2.val.sl;	\
 	else						\
 		r.val.ul = v1.val.ul OP v2.val.ul;
 
@@ -83,7 +83,7 @@
 	else if(cv_signed(v1) && !cv_signed(v2))	\
 		r.val.sll = v1.val.sll OP v2.val.ull;	\
 	else if(!cv_signed(v1) && cv_signed(v2))	\
-		r.val.ull = v1.val.ull OP v2.val.sll;	\
+		r.val.sll = v1.val.ull OP v2.val.sll;	\
 	else						\
 		r.val.ull = v1.val.ull OP v2.val.ull;
 
-- 
1.7.2.2



More information about the wine-patches mailing list