Fix lrot.c: Shifting by the width of the left operand results in undefined behaviour.
authorChristoph Mallon <christoph.mallon@gmx.de>
Mon, 25 Aug 2008 19:44:20 +0000 (19:44 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Mon, 25 Aug 2008 19:44:20 +0000 (19:44 +0000)
[r21464]

ir/be/test/lrot.c

index 2bc7247..737581d 100644 (file)
@@ -6,11 +6,11 @@
 #define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))
 
 unsigned long long testL(unsigned long long a, int cnt) {
-       return ROL(a, cnt);
+       return cnt == 0 ? a : ROL(a, cnt);
 }
 
 unsigned long long testR(unsigned long long a, int cnt) {
-       return ROR(a, cnt);
+       return cnt == 0 ? a : ROR(a, cnt);
 }
 
 int main() {