[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 11:23:41 PDT 2024


kees wrote:

> > I’m a little concerned about not allowing the attribute in C++ - the existence of other options in C++ does not mean they are an option (due to various and sundry restrictions of C++ version upgrades different projects have), but also you trivially end up in cases where header code is correct/safe in C, but undefined when included in C++.
> > To me that seems like a significant footgun.
> 
> Yes, great point. The attribute should support C++ fairly well right now but the frontend doesn't allow it to be enabled because I am not certain how the magics of the c++ type/attribute system will interact with it. I figured a good starting point is to get the attribute working with C.
> 
> other comment in thread about avoiding issues by disabling c++ support: [#86618 (comment)](https://github.com/llvm/llvm-project/pull/86618#issuecomment-2050356907)

So looking at what it'd take for C++ support, I don't think it's worth it right now. We already don't parse it in the front-end under C++ so there's no risk of some behavior changing -- it cannot be defined at all right now there. Additionally, since this was introduced because of C's lack of operator overloading, it feels redundant to add this to C++. And finally, there is no C++ user that actually wants this attribute.

So let's leave it as-is with only C support: that's where it's wanted, and that's where it will be exclusively used.

https://github.com/llvm/llvm-project/pull/86618


More information about the cfe-commits mailing list