On December 31, 2015 10:17:34 AM GMT+01:00, Jakub Jelinek <ja...@redhat.com> wrote: >Hi! > >ubsan_instrument_float_cast is called from convert.c, therefore for all >FEs >that uses convert.c. For C/C++, the ubsan builtins are already >initialized >through their inclusion from builtins.def, but for other builtins they >can >be still uninitialized. This patch adds a call that ensures the >builtins >are initialized when we need them in ubsan_instrument_float_cast. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/5?
OK. Though I wonder if ubsan makes sense for non-C-family languages. Richard. >2015-12-31 Jakub Jelinek <ja...@redhat.com> > > PR sanitizer/69055 > * ubsan.c (ubsan_instrument_float_cast): Call > initialize_sanitizer_builtins. > > * gfortran.dg/pr69055.f90: New test. > >--- gcc/ubsan.c.jj 2015-11-09 13:39:32.000000000 +0100 >+++ gcc/ubsan.c 2015-12-28 10:22:23.024610469 +0100 >@@ -1588,6 +1588,7 @@ ubsan_instrument_float_cast (location_t > { > location_t *loc_ptr = NULL; > unsigned num_locations = 0; >+ initialize_sanitizer_builtins (); > /* Figure out if we can propagate location to ubsan_data and use new > style handlers in libubsan. */ > if (ubsan_use_new_style_p (loc)) >--- gcc/testsuite/gfortran.dg/pr69055.f90.jj 2015-12-28 >10:28:58.925048460 +0100 >+++ gcc/testsuite/gfortran.dg/pr69055.f90 2015-12-28 10:28:53.082130547 >+0100 >@@ -0,0 +1,10 @@ >+! { dg-do compile } >+! { dg-options "-fsanitize=float-cast-overflow" } >+ >+subroutine pr69055 >+ implicit none >+ integer :: n >+ real(8) :: b >+ b = huge(1.0D0) >+ n = b >+end subroutine pr69055 > > Jakub