On Tuesday 09 May 2017, Daniel Santos wrote: > The primary aim is to facilitate high-performance generic C > libraries for software where C++ is not suitable, but the cost of > run-time abstraction is unacceptable. A good example is the Linux > kernel, where the source tree is littered with more than 100 hand-coded > or boiler-plate (copy, paste and edit) search cores required to use the > red-black tree library. That is not a good excuse, they can just use a defined subset of C++. The cost of C++ abstractions is zero if you don't use them.
> > To further the usefulness of such techniques, I propose the addition of > a c-family attribute to declare a parameter, variable (and possibly > other declarations) as "constprop" or some similar word. The purpose of > the attribute is to: > > 1.) Emit a warning or error when the value is not optimized away, and > 2.) Direct various optimization passes to prefer (or force) either > cloning or inlining of a function with such a parameter. > This I can get more behind, I have wanted a constexpr attribute for C for some time. If not for anything else to be able to use it in shared/system headers that can be used by both C and C++ and in C++ would be useful in constexpr expressions. If you can find a use for it in pure C as well, so much the better. `Allan