From 826c76952b45098f2d090fb3c292707a872e20ce Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Tue, 16 Jan 2018 11:41:12 +0000 Subject: COMPMID-835: Valgrind make UNIT/Utils/RoundFloatToNearestUp fail on aarch64 Workaround for Valgrind round() issue on aarch64. Valgrind's call to std::round(-4.500000) == -4.000000 instead of 5.00000. I think there is a bug in valgrind's code for aarch64 where the rounding mode is not properly setup and that's the reason why round to zero is used all the time. Change-Id: If8fbee98e022856fcc48e454f7afd447f1f193e9 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/116457 Tested-by: Jenkins Reviewed-by: Michalis Spyrou Reviewed-by: Georgios Pinitas Reviewed-by: Anthony Barbier --- support/ToolchainSupport.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'support') diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h index e3c0c2761d..56cbce8cc4 100644 --- a/support/ToolchainSupport.h +++ b/support/ToolchainSupport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -246,7 +246,8 @@ int stof(Ts &&... args) template ::value>::type> inline T round(T value) { - return std::round(value); + //Workaround Valgrind's mismatches: when running from Valgrind the call to std::round(-4.500000) == -4.000000 instead of 5.00000 + return (value < 0.f) ? static_cast(value - 0.5f) : static_cast(value + 0.5f); } /** Truncate floating-point value. -- cgit v1.2.1