C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[unevaluated]]

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 21 May 2026 07:27:39 +0000
>
> Thiago wrote:
>
> >> There isn't a snowball's chance in hell that attributes will stay
> >> ignorable forever. No way José.
>
> > Can you share your crystal ball?
> > It might be cracked, though.
>



Maybe I need to write a paper about this but I'll give a quick summary for
now.

C++ is an old language now and there's billions of lines of code written in
it already. If we add a keyword to the language now, it will probably break
code somewhere that uses that keyword as a variable's name. We can prepend
"__" or "_uppercase" to the new keyword name, or alternatively Ville
mentioned about having context-dependent keywords, but I think there's a
better solution.

I haven't seen the innards of many compilers, but at least the GNU compiler
has a robust system in place for the handling of attributes on variables
and functions. When I was implementing 'interceptor' functions, I was able
to just add the word 'interceptor' to an array of strings and provide a
handler function something like "handler_attribute_interceptor". This makes
it so much easier and less likely to introduce bugs than if I were to edit
the parser to look out for a word. Attributes are convenient for compiler
implementors.

I realise that attributes started out as ignorable, but there's so much
more possibility if we make some of them non-ignorable. Maybe the easiest
way to do this is to use three brackets instead of two. So in effect, using
two brackets would mean "Hi compiler, I'd like you to do this but it's okay
if you don't", and using three brackets would mean "Hi compiler, you must
do this".

And by the way, the whole ignorable thing is a bit wishy-washy. Because if
[[no_unique_address]] is honoured in one translation unit, and ignored in
another, then you have an ABI conflict. So when the standard says
'ignorable', does it at least say 'ignorable but only if the ignoring is
consistent'? I'll actually open up the Standard PDF file now and check.

Received on 2026-05-21 07:27:43