This is the mail archive of the
mailing list for the GCC project.
Re: [RFC] GCC 8 Project proposal: Extensions supporting C Metaprogramming, pseudo-templates
- From: Allan Sandfeld Jensen <linux at carewolf dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Daniel Santos <daniel dot santos at pobox dot com>, Joseph Myers <joseph at codesourcery dot com>, Richard Henderson <rth at redhat dot com>
- Date: Tue, 9 May 2017 15:29:52 +0200
- Subject: Re: [RFC] GCC 8 Project proposal: Extensions supporting C Metaprogramming, pseudo-templates
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
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