Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's an excerpt from Section 6.7.1 (footnote 101) of the <a href="http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf" rel="nofollow noreferrer">C99 standard (pdf)</a>:</p> <blockquote> <p>The implementation may treat any <code>register</code> declaration simply as an <code>auto</code> declaration. However, <strong>whether or not addressable storage is actually used, the address of any part of an object declared with storage-class specifier register cannot be computed</strong>, either explicitly (by use of the unary <code>&amp;</code> operator as discussed in 6.5.3.2) or implicitly (by converting an array name to a pointer as discussed in 6.3.2.1). Thus, the only operator that can be applied to an array declared with storage-class specifier <code>register</code> is <code>sizeof</code>.</p> </blockquote> <p>And from Section 7.1.1, Paragraph 3 of the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf" rel="nofollow noreferrer">C++ standard (pdf)</a>:</p> <blockquote> <p>A <code>register</code> specifier has the same semantics as an <code>auto</code> specifier together with a hint to the implementation that the object so declared will be heavily used. <strong>[Note: the hint can be ignored and in most implementations it will be ignored if the address of the object is taken. —end note]</strong></p> </blockquote> <h2>Fun tidbits about <code>register</code></h2> <p>The C++ group (WG21) <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#809" rel="nofollow noreferrer">wants to deprecate <code>register</code></a>:</p> <blockquote> <p>The <code>register</code> keyword serves very little function, offering no more than a hint that a note says is typically ignored. It should be deprecated in this version of the standard, freeing the reserved name up for use in a future standard, much like <code>auto</code> has been re-used this time around for being similarly useless. </p> <p><strong>Notes from the March, 2009 meeting:</strong></p> <p>The consensus of the CWG was in favor of deprecating <code>register</code>.</p> </blockquote> <p>Look what the C99 group (WG14) <a href="http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1300.pdf" rel="nofollow noreferrer">said about <code>register</code> (pdf)</a> at a meeting:</p> <blockquote> <p>General agreement to deprecate the “<code>auto</code>” keyword. Should we ask WG21 to go back to the previous use of “<code>register</code>” (no address)? No, this will not fly with WG21.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload