[Beignet] [PATCH] Fix compiler error

yyc1992 at gmail.com yyc1992 at gmail.com
Wed Jul 19 21:57:16 UTC 2017


From: Yichao Yu <yyc1992 at gmail.com>

There's no overload for `std::abs` or `abs` that takes `unsigned int` as input so this causes
an ambiguity when both `std::abs` and `abs` are available in the namespace.
Explicitly cast the `unsigned int` to `int` to resolve the ambiguity.
---
 backend/src/backend/gen_insn_selection_optimize.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp b/backend/src/backend/gen_insn_selection_optimize.cpp
index 2ab2a7f9..8ecc1a74 100644
--- a/backend/src/backend/gen_insn_selection_optimize.cpp
+++ b/backend/src/backend/gen_insn_selection_optimize.cpp
@@ -459,13 +459,13 @@ namespace gbe
             {
               unsigned int s0 = src0.value.ud;
               if (src0.absolute)
-                s0 = abs(s0);
+                s0 = abs((int)s0);
               if (src0.negation)
                 s0 = -s0;
 
               unsigned int s1 = src1.value.ud;
               if (src1.absolute)
-                s1 = abs(s1);
+                s1 = abs((int)s1);
               if (src1.negation)
                 s1 = -s1;
 
-- 
2.13.3



More information about the Beignet mailing list