Date: Mon, 6 Jul 2026 16:27:19 +0200
Hello,
Il 05/07/26 10:54, Jāāā Gustedt ha scritto:
> Hi,
> apologies again that I will not be able to make it to the meeting.
>
> on Sun, 28 Jun 2026 10:25:22 +0200 you (Jan Schultke
> <janschultke_at_googlemail.com>) wrote:
>
>> - P3093R0
>> <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3093r0.html>
>> Attributes
>> on expressions (Giuseppe D'Angelo)
>
> I like the paper and think that the chosen syntax is a good one. That
> is definitively material that we should prospect putting into C,
> too. (But we'd need implementations, first.)
>
> The paper seems to be incomplete, but maybe I overlooked an
> explanation for this: I think there should also be wording that adds
> this new possibility to some standard attributes. For C come to mind
> all standard attributes with the exeption of `[[fallthrough]]`, but
> C++ has probably more attributes that would be interesting on
> expressions.
>
> I get it, that some of these standard attributes would need discussion
> in a separate paper to clarify the semantics, but others should be
> quite direct.
Thank you for your feedback.
To clarify a bit around the context, I did have a separate proposal
(P2992, attribute [[discard("reason")]]) which was meant to be an
attribute on expressions (and on statements). Unfortunately it didn't
pass EWG, so now I don't really have a poster-child attribute on
expressions...
Regarding the existing standard C++ attributes, I am not quite sure that
any of them could meaningfully be applied to expressions; maybe just
[[likely]]?
For the others:
* [[noreturn]] is for function declarations. Maybe one could entertain
the idea that the evaluation of an expression never returns, but I'm not
sure what it would mean. (It could also be emulated today by applying
[[noreturn]] to an IILE.)
* [[deprected]] is for declarations, not statements in general and not
expressions. What what would it mean that an expression is "deprecated"?
* [[fallthrough]] is for null statements only, doesn't make sense for an
expression;
* [[maybe_unused]] is for "entity declarations" at large, doesn't make
sense for an expression;
* [[nodiscard]] is for functions and enum/class declarations. I don't
get why one would write [[nodiscard]] for an expression -- just use the
result if you don't want it to be discarded?
* [[no_unique_address]] is for NSDMs, doesn't make sense for an expression;
* [[assume(expr)]] is deliberately NOT on an expression one assumes,
since that expression is meant to be unevaluated;
* [[indeterminate]] is only for automatic variables, doesn't make sense
for an expression.
Thank you,
--
Giuseppe D'Angelo
Il 05/07/26 10:54, Jāāā Gustedt ha scritto:
> Hi,
> apologies again that I will not be able to make it to the meeting.
>
> on Sun, 28 Jun 2026 10:25:22 +0200 you (Jan Schultke
> <janschultke_at_googlemail.com>) wrote:
>
>> - P3093R0
>> <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3093r0.html>
>> Attributes
>> on expressions (Giuseppe D'Angelo)
>
> I like the paper and think that the chosen syntax is a good one. That
> is definitively material that we should prospect putting into C,
> too. (But we'd need implementations, first.)
>
> The paper seems to be incomplete, but maybe I overlooked an
> explanation for this: I think there should also be wording that adds
> this new possibility to some standard attributes. For C come to mind
> all standard attributes with the exeption of `[[fallthrough]]`, but
> C++ has probably more attributes that would be interesting on
> expressions.
>
> I get it, that some of these standard attributes would need discussion
> in a separate paper to clarify the semantics, but others should be
> quite direct.
Thank you for your feedback.
To clarify a bit around the context, I did have a separate proposal
(P2992, attribute [[discard("reason")]]) which was meant to be an
attribute on expressions (and on statements). Unfortunately it didn't
pass EWG, so now I don't really have a poster-child attribute on
expressions...
Regarding the existing standard C++ attributes, I am not quite sure that
any of them could meaningfully be applied to expressions; maybe just
[[likely]]?
For the others:
* [[noreturn]] is for function declarations. Maybe one could entertain
the idea that the evaluation of an expression never returns, but I'm not
sure what it would mean. (It could also be emulated today by applying
[[noreturn]] to an IILE.)
* [[deprected]] is for declarations, not statements in general and not
expressions. What what would it mean that an expression is "deprecated"?
* [[fallthrough]] is for null statements only, doesn't make sense for an
expression;
* [[maybe_unused]] is for "entity declarations" at large, doesn't make
sense for an expression;
* [[nodiscard]] is for functions and enum/class declarations. I don't
get why one would write [[nodiscard]] for an expression -- just use the
result if you don't want it to be discarded?
* [[no_unique_address]] is for NSDMs, doesn't make sense for an expression;
* [[assume(expr)]] is deliberately NOT on an expression one assumes,
since that expression is meant to be unevaluated;
* [[indeterminate]] is only for automatic variables, doesn't make sense
for an expression.
Thank you,
--
Giuseppe D'Angelo
Received on 2026-07-06 14:27:24
