[cfe-dev] [LLVMdev] ubsan - active member check for unions

Caldarale, Charles R Chuck.Caldarale at unisys.com
Sat Dec 20 05:39:56 PST 2014


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] 
> On Behalf Of Joerg Sonnenberger
> Subject: Re: [LLVMdev] [cfe-dev] ubsan - active member check for unions

> On Fri, Dec 19, 2014 at 06:59:48PM -0800, Richard Smith wrote:
> > On Thu, Dec 18, 2014 at 11:05 PM, Yury Gribov <y.gribov at samsung.com> wrote:
> > > Anyway, the pattern is so widespread that IMHO most maintainers will find
> > > such errors useless.

> > Well, given that this is the bug that the sanitizer is built to detect,
> > such maintainers should not turn it on.

> I agree with Yury that there are a few cases where it is the standard
> approach and flagging it as error doesn't make sense. Question is
> whether we can enumerate those cases and white list them. I know unions
> are used in mathematical code for accesing floats as int and vice versa,
> not sure about any thing else.

Often used when dealing with bare hardware and the types of fields are dependent on other information, so several are folded into one union.

 - Chuck





More information about the cfe-dev mailing list