[Piglit] [PATCH 2/3] util: Disable "overflow in floating-point constant arithmetic" in strtod_inf.

Emil Velikov emil.l.velikov at gmail.com
Wed Dec 3 14:19:17 PST 2014


On 03/12/14 15:37, Jose Fonseca wrote:
> From: José Fonseca <jfonseca at vmware.com>
> 
> Now that this is an inline function, the warning appears all over the
> place.
> ---
>  tests/util/piglit-util.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
> index 90d57d3..099075a 100755
> --- a/tests/util/piglit-util.h
> +++ b/tests/util/piglit-util.h
> @@ -187,6 +187,9 @@ strtod_inf(const char *nptr, char **endptr)
>  	while (*nptr == ' ' || *nptr == '\t')
>  		nptr++;
>  
> +#pragma warning( push )
> +#pragma warning( disable : 4056 ) // overflow in floating-point constant arithmetic
> +#pragma warning( disable : 4756 ) // overflow in constant arithmetic
>
Haven't checked but I guess that those will trigger warnings with
gcc/clang/others:
   warning: ignoring #pragma warning

As -Wall pulls in -Wunknown-pragmas. The former being set in CMakeLists.txt

Maybe wrap them in ifdef _MSC_VER or add -Wno-unknown-pragmas to the
CMAKE_C{,XX}_FLAGS ?

Cheers,
Emil

>  	if (nptr[0] == 'i' && nptr[1] == 'n' && nptr[2] == 'f') {
>  		/* +infinity */
>  		*endptr = (char *) (nptr + 3);
> @@ -197,6 +200,8 @@ strtod_inf(const char *nptr, char **endptr)
>  		*endptr = (char *) (nptr + 4);
>  		return -INFINITY;
>  	}
> +#pragma warning( pop )
> +
>  	/* fall-through */
>  #endif
>  	return strtod(nptr, endptr);
> 



More information about the Piglit mailing list