This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

On 05/09/2017 01:36 AM, Daniel Santos wrote:
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.

I think GCC used to treat C and C++ constant expressions this way in the old days. That is, what was a constant expression depended to some degree on the capabilities of the folder at least (and maybe the optimizers). This wasn't such a great idea because it made behavior inconsistent across architectures and GCC versions.

There are also thorny specification issues, like is an array whose length is a constprop value a VLA or not?

If you are interested in metaprogramming techniques, you are probably better off writing code generators or using a C++ subset.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]