[RFC] GCC 8 Project proposal: Extensions supporting C Metaprogramming, pseudo-templates

Jonathan Wakely jwakely.gcc@gmail.com
Thu May 11 10:12:00 GMT 2017

On 10 May 2017 at 23:14, Daniel Santos wrote:
> Well my primary goal is programming with values that are constant in the
> compiler.  There is no language in any C specification (that I'm aware of)
> for a "compile-time constant", but the concept is very important.  So just
> because some expression is a compile-time constant doesn't mean we morph
> into a "constant expression" (as per the spec), even with
> __attribute__((const)).

The C standard says "An implementation may accept other forms of
constant expressions." That means rather than inventing some
"constprop" you could just extend GCC to treat more expressions
involving constants as constant-expressions.

There are enhancement requests for this in Bugzilla, because some
compilers are already more catholic in what they accept in constant
expressions (notably, Clang).

More information about the Gcc mailing list