[cfe-dev] recent change broke -fcatch-undefined-behavior

Sean McBride sean at rogue-research.com
Tue Nov 27 14:32:41 PST 2012


On Fri, 23 Nov 2012 16:40:57 -0500, Sean McBride said:

>I'm seeing some other weirdness with -fsanitize=float-cast-overflow:
>
><unknown>: fatal error: value 255 is outside the range of representable
>values of type 'unsigned char'
>
>hmmm, could there be an off-by-one error in the check here?

Regarding this, it would be helpful if ubsan output the exact value of the floating point value.  Consider:

#if 1
  float foo = 256.001f;
  printf("foo is %f\n", foo);
	 fflush(NULL);
  uint8_t bar = foo;
#else
  float foo = 256.0001f;
  printf("foo is %f\n", foo);
	 fflush(NULL);
  uint8_t bar = foo;
#endif

The first case gets me:

foo is 256.001007
<unknown>: fatal error: value 256.001 is outside the range of representable values of type 'unsigned char'

the second:

foo is 256.000092
<unknown>: fatal error: value 256 is outside the range of representable values of type 'unsigned char'

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada






More information about the cfe-dev mailing list