[LLVMdev] ubsan - active member check for unions
Yury Gribov
y.gribov at samsung.com
Thu Dec 18 23:05:30 PST 2014
On 12/19/2014 01:14 AM, Nick Lewycky wrote:
> On 12/16/2014 02:43 AM, Yury Gribov wrote:
>> On 12/15/2014 10:24 PM, Ismail Pazarbasi wrote:
>>> s.d = 42.0;
>>> if (s.l > 100) // fire here
>>
>> Note that code like this is frequently used to convert integers to
>> floats so you'll get tons of false positives.
>
> True positives. The fix is to use memcpy instead.
Hm, I thought C aliasing rules explicitly allow changing types through
unions. Anyway, the pattern is so widespread that IMHO most maintainers
will find such errors useless.
-Y
More information about the llvm-dev
mailing list