diff mbox

Fix an UBSAN test-case (PR sanitizer/63361).

Message ID 79d1f367-ec07-8eb8-6d06-a14d2396d738@suse.cz
State New
Headers show

Commit Message

Martin Liška July 18, 2017, 11:44 a.m. UTC
Hello.

This should address spotted in the PR, where I basically implemented what
I was recommended in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63361#c14.

Ready for trunk?
Thanks,
Martin

Comments

Jakub Jelinek July 18, 2017, 11:49 a.m. UTC | #1
On Tue, Jul 18, 2017 at 01:44:21PM +0200, Martin Liška wrote:
> gcc/testsuite/ChangeLog:
> 
> 2017-07-17  Martin Liska  <mliska@suse.cz>
> 
> 	PR sanitizer/63361
> 	* c-c++-common/ubsan/float-cast-overflow-1.c: Add either
> 	-ffloat-store or -mieee for targets that need it.
> ---
>  gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
> index cd6941c9d30..a25e8dea29e 100644
> --- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
> +++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
> @@ -1,6 +1,7 @@
>  /* { dg-do run { target { lp64 || ilp32 } } } */
> +/* { dg-additional-options "-mfloat-store" { target { ia32 m68k-*-* } } } */

-ffloat-store, not -mfloat-store, that doesn't exist.

I wonder if one can mix effective target names with target tripplets this
way.  If it works, fine, otherwise I guess you'd need { { ia32 } || { m68k-*-* } }
or something similar.  Can you please test it?
First make sure that for RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp=float-cast-overflow-1.c'
you get -ffloat-store for 32-bit and not 64-bit.
I guess you don't have m68k-*-* target around, so next step I'd temporarily
change that m68k to x86_64 and retry and see if it enabled on both.

> +/* { dg-additional-options "-mieee" { target { alpha* sh* } } } */

I'd prefer alpha*-*-* sh*-*-*

>  /* { dg-options "-fsanitize=float-cast-overflow" } */
> -/* { dg-additional-options "-msse2 -mfpmath=sse" { target { sse2_runtime && ia32 } } } */

	Jakub
Martin Liška July 19, 2017, 6:50 a.m. UTC | #2
On 07/18/2017 01:49 PM, Jakub Jelinek wrote:
> On Tue, Jul 18, 2017 at 01:44:21PM +0200, Martin Liška wrote:
>> gcc/testsuite/ChangeLog:
>>
>> 2017-07-17  Martin Liska  <mliska@suse.cz>
>>
>> 	PR sanitizer/63361
>> 	* c-c++-common/ubsan/float-cast-overflow-1.c: Add either
>> 	-ffloat-store or -mieee for targets that need it.
>> ---
>>   gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
>> index cd6941c9d30..a25e8dea29e 100644
>> --- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
>> +++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
>> @@ -1,6 +1,7 @@
>>   /* { dg-do run { target { lp64 || ilp32 } } } */
>> +/* { dg-additional-options "-mfloat-store" { target { ia32 m68k-*-* } } } */
> 
> -ffloat-store, not -mfloat-store, that doesn't exist.
> 
> I wonder if one can mix effective target names with target tripplets this
> way.  If it works, fine, otherwise I guess you'd need { { ia32 } || { m68k-*-* } }
> or something similar.  Can you please test it?
> First make sure that for RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp=float-cast-overflow-1.c'
> you get -ffloat-store for 32-bit and not 64-bit.
> I guess you don't have m68k-*-* target around, so next step I'd temporarily
> change that m68k to x86_64 and retry and see if it enabled on both.
> 
>> +/* { dg-additional-options "-mieee" { target { alpha* sh* } } } */
> 
> I'd prefer alpha*-*-* sh*-*-*
> 
>>   /* { dg-options "-fsanitize=float-cast-overflow" } */
>> -/* { dg-additional-options "-msse2 -mfpmath=sse" { target { sse2_runtime && ia32 } } } */
> 
> 	Jakub
> 

Thanks Jakub. Tested that and installed as r250336.

Martin
diff mbox

Patch

From 92ca98e49112cc164739ebd1f1a00bcc13704331 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 17 Jul 2017 15:22:25 +0200
Subject: [PATCH] Fix an UBSAN test-case (PR sanitizer/63361).

gcc/testsuite/ChangeLog:

2017-07-17  Martin Liska  <mliska@suse.cz>

	PR sanitizer/63361
	* c-c++-common/ubsan/float-cast-overflow-1.c: Add either
	-ffloat-store or -mieee for targets that need it.
---
 gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
index cd6941c9d30..a25e8dea29e 100644
--- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c
@@ -1,6 +1,7 @@ 
 /* { dg-do run { target { lp64 || ilp32 } } } */
+/* { dg-additional-options "-mfloat-store" { target { ia32 m68k-*-* } } } */
+/* { dg-additional-options "-mieee" { target { alpha* sh* } } } */
 /* { dg-options "-fsanitize=float-cast-overflow" } */
-/* { dg-additional-options "-msse2 -mfpmath=sse" { target { sse2_runtime && ia32 } } } */
 
 #include <limits.h>
 #include "float-cast.h"
-- 
2.13.2