diff mbox

Workaround extended precision decimal computations in float-cast-overflow-10.c (PR sanitizer/79341)

Message ID 20170210195805.GV1849@tucnak
State New
Headers show

Commit Message

Jakub Jelinek Feb. 10, 2017, 7:58 p.m. UTC
Hi!

Apparently on s390x with -march=z10 and above at -O2, some of the _Decimal32
computations are performed in _Decimal64 precision.  As the test intent
is to test the diagnostics on cast from floating point types to integral
types, the values we want to cast matter most (we want values that are
smallest or largest values already not representable in the integral type),
and already use volatile for the tem variable, so I think it is fine to
extend it.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-02-10  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/79341
	* c-c++-common/ubsan/float-cast-overflow-8.c (TEST): Make min and max
	variables volatile.


	Jakub

Comments

Jeff Law Feb. 13, 2017, 10:56 p.m. UTC | #1
On 02/10/2017 12:58 PM, Jakub Jelinek wrote:
> Hi!
>
> Apparently on s390x with -march=z10 and above at -O2, some of the _Decimal32
> computations are performed in _Decimal64 precision.  As the test intent
> is to test the diagnostics on cast from floating point types to integral
> types, the values we want to cast matter most (we want values that are
> smallest or largest values already not representable in the integral type),
> and already use volatile for the tem variable, so I think it is fine to
> extend it.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-02-10  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR sanitizer/79341
> 	* c-c++-common/ubsan/float-cast-overflow-8.c (TEST): Make min and max
> 	variables volatile.
OK.
jeff
diff mbox

Patch

--- gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c.jj	2015-10-29 09:14:30.000000000 +0100
+++ gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-8.c	2017-02-10 18:09:47.767251774 +0100
@@ -8,7 +8,7 @@ 
 #define TEST(type1, type2) \
   if (type1##_MIN)						\
     {								\
-      type2 min = type1##_MIN;					\
+      volatile type2 min = type1##_MIN;				\
       type2 add = -1.0;						\
       while (1)							\
 	{							\
@@ -28,7 +28,7 @@ 
       volatile type1 tem3 = cvt_##type1##_##type2 (-1.0f);	\
     }								\
   {								\
-    type2 max = type1##_MAX;					\
+    volatile type2 max = type1##_MAX;				\
     type2 add = 1.0;						\
     while (1)							\
       {								\