re PR sanitizer/88426 (Compiler crash if use special code with command line switch -fsanitize=float-cast-overflow)

PR sanitizer/88426
	* c-convert.c (convert): Call c_fully_fold before calling
	ubsan_instrument_float_cast.

	* c-c++-common/ubsan/float-cast-overflow-11.c: New test.

From-SVN: r267022
This commit is contained in:
Jakub Jelinek 2018-12-11 14:51:44 +01:00 committed by Jakub Jelinek
parent ef9fc3ba34
commit 6d9391732b
4 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2018-12-11 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/88426
* c-convert.c (convert): Call c_fully_fold before calling
ubsan_instrument_float_cast.
2018-12-08 Segher Boessenkool <segher@kernel.crashing.org>
* c-parser (c_parser_asm_statement) [RID_INLINE]: Delete stray line

View File

@ -115,6 +115,7 @@ convert (tree type, tree expr)
&& COMPLETE_TYPE_P (type))
{
expr = save_expr (expr);
expr = c_fully_fold (expr, false, NULL);
tree check = ubsan_instrument_float_cast (loc, type, expr);
expr = fold_build1 (FIX_TRUNC_EXPR, type, expr);
if (check == NULL_TREE)

View File

@ -1,3 +1,8 @@
2018-12-11 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/88426
* c-c++-common/ubsan/float-cast-overflow-11.c: New test.
2018-12-11 Yannick Moy <moy@adacore.com>
* gnat.dg/ghost4.adb: New testcase.

View File

@ -0,0 +1,10 @@
/* PR sanitizer/88426 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=float-cast-overflow" } */
int
foo (void)
{
const float v = 0.0f;
return (int) (v < 0.0f ? v : 0.0f);
}