Document number: P0479R4
Date: 2018-02-07
Audience: Core Working Group, SG14
Reply-to: Clay Trychta <clay.trychta@gmail.com>

Proposed wording for likely and unlikely attributes (Revision 4)

Wording

10.6.N Likelihood attributes [dcl.attr.likelihood]

The attribute-tokens likely and unlikely may be applied to statements. The attribute-tokens likely and unlikely shall appear at most once in each attribute-list and no attribute-argument-clause shall be present. The likely attribute is not allowed to appear in the same attribute-list as the unlikely attribute.

[Note: The use of the likely attribute on a statement is intended to allow implementations to optimize for the case where paths of execution including that statement are arbitrarily more likely than any alternative path of execution that does not include such a statement. The use of the unlikely attribute on a statement is intended to allow implementations to optimize for the case where paths of execution including that statement are arbitrarily more unlikely than any alternative path of execution that does not include such a statement. Excessive usage of either of these attributes is liable to result in performance degradation. — end note]

Acknowledgements

Thank you to Chandler Carruth, Andrew Pardoe, Davis Herring, John McFarlane, Bartosz Bielecki, Carl Cook, Matt Dziubinski, Mathias Gaunard, Paul Hampson, and others in SG14 for sharing their insights and suggestions.