Automatic variable: Difference between revisions

Content deleted Content added
Pemu (talk | contribs)
No edit summary
C, C++: update footnote on auto
Line 12:
(Called ''automatic'' variables.)
 
All variables declared within a [[block (programming)|block]] of code are automatic by default, but this can be made explicit with the <code>auto</code> keyword.<ref group="note">Note: the currentrecent C++ standardstandards, specifically [[C++11]], addsand anlater, additionalchange the meaning toof the <code>auto</code> keyword, meaning a typeusing thatit isfor [[Typetype inference|inferred]] and an alternate function declaration syntax.</ref> An uninitialized automatic variable has an [[undefined behavior|undefined]] value until it is assigned a valid value of its type.<ref>{{As of|2008|alt=Current}} {{PDFlink|[http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf C standard]|3.61&nbsp;[[Mebibyte|MiB]]<!-- application/pdf, 3788603 bytes -->}}: section 6.2.4, Storage durations of objects</ref>
 
Using the storage class <code>register</code> instead of <code>auto</code> is a hint to the compiler to cache the variable in a processor register. Other than not allowing the referencing operator (<code>&</code>) to be used on the variable or any of its subcomponents, the compiler is free to ignore the hint.