<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3147: Definitions of "likely" and "unlikely" are likely to cause problems</title>
<meta property="og:title" content="Issue 3147: Definitions of &quot;likely&quot; and &quot;unlikely&quot; are likely to cause problems">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3147.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++20">C++20</a> status.</em></p>
<h3 id="3147"><a href="lwg-defects.html#3147">3147</a>. Definitions of "likely" and "unlikely" are likely to cause problems</h3>
<p><b>Section:</b> 16.4.5.3.3 <a href="https://wg21.link/macro.names">[macro.names]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Casey Carter <b>Opened:</b> 2018-08-01 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</p>
<p><b>View other</b> <a href="lwg-index-open.html#macro.names">active issues</a> in [macro.names].</p>
<p><b>View all other</b> <a href="lwg-index.html#macro.names">issues</a> in [macro.names].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
16.4.5.3.3 <a href="https://wg21.link/macro.names">[macro.names]</a>/2 forbids a translation unit to define names "lexically identical to [&hellip;] the 
<i>attribute-token</i>s described in 9.13 <a href="https://wg21.link/dcl.attr">[dcl.attr]</a>." We recently added the attribute-tokens <code>likely</code> 
and <code>unlikely</code> (9.13.7 <a href="https://wg21.link/dcl.attr.likelihood">[dcl.attr.likelihood]</a>). These names are in extremely wide use as function-like 
macros in the open source community, forbidding users to define them breaks large amounts of code. (Reportedly 
Chromium contains 19 definitions each of "likely" and "unlikely" as function-like macros.)
<p/>
Indeed, this issue came up during EWG discussion of <a href="https://wg21.link/p0479R1">P0479R1</a> "Attributes 
for Likely and Unlikely Statements" in Kona, and EWG decided to keep the names "likely" and "unlikely" for the attribute 
tokens since the usage wouldn't conflict with defining them as function-like macros. 16.4.5.3.3 <a href="https://wg21.link/macro.names">[macro.names]</a>/2 should 
not break large amounts of existing code that doesn't actually conflict with the use of the <code>[[likely]]</code> and 
<code>[[unlikely]]</code> attributes.
</p>

<p><i>[2018-08-20 Status to Tentatively Ready after five positive votes on the reflector.]</i></p>

<p><i>[2018-11, Adopted in San Diego]</i></p>



<p id="res-3147"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.
</p>

<ol>
<li>
<p>Change 16.4.5.3.3 <a href="https://wg21.link/macro.names">[macro.names]</a> as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting Note:</i> If both this proposed resolution and the proposed resolution of LWG <a href="lwg-defects.html#3132" title="Library needs to ban macros named expects or ensures (Status: C++20)">3132</a><sup><a href="https://cplusplus.github.io/LWG/issue3132" title="Latest snapshot">(i)</a></sup> are accepted, 
the text inserted by LWG <a href="lwg-defects.html#3132" title="Library needs to ban macros named expects or ensures (Status: C++20)">3132</a><sup><a href="https://cplusplus.github.io/LWG/issue3132" title="Latest snapshot">(i)</a></sup> should precede the text added here.]
</p>
</blockquote>

<blockquote>
<p>
-2- A translation unit shall not <code>#define</code> or <code>#undef</code> names lexically identical to keywords, to 
the identifiers listed in Table 4, or to the <i>attribute-token</i>s described in 9.13 <a href="https://wg21.link/dcl.attr">[dcl.attr]</a><ins>, 
except that the names <code>likely</code> and <code>unlikely</code> may be defined as function-like macros 
(15.7 <a href="https://wg21.link/cpp.replace">[cpp.replace]</a>)</ins>.
</p>
</blockquote>
</li>
</ol>





</body>
</html>
