Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It appears that as far as your first result goes, VC++ still follows the rule from C89/90, which said (§ 6.1.3.2):</p> <blockquote> <p>The type of an integer constant is the first of the corresponding list in which its value can be represented. Unsuffixed decimal: <code>int</code>, <code>long int</code>, <code>unsigned long int</code>; [...]</p> </blockquote> <p>So, since 4294967295 can be represented as an <code>unsigned long int</code>, that's what it's using.</p> <p>In C++98/03, this is still permitted, but no longer required -- you're using a value larger than can be represented in an <code>long int</code>, which gives undefined behavior (§ 2.13.1/2):</p> <blockquote> <p>If it is decimal and has no suffix, it has the first of these types in which its value can be represented: <code>int</code>, <code>long int</code>; <strong>if the value cannot be represented as a long int, the behavior is undefined.</strong></p> </blockquote> <p>[emphasis added]</p> <p>C++11 adds <code>long long int</code> to the list, so that's the type <code>4294967295</code> <em>should</em> become, but even in VC++ 2013 RC, it still follows the C89/90 standard in this respect and gives it type <code>unsigned long int</code>.</p> <p>Note that the the string produced by <code>typeid</code> is implementation defined, so it doesn't have to correspond directly to the proper name of the type. If you use overloading, we can see that <code>0x100000000</code> and <code>4294967296</code> have type <code>long long</code> though:</p> <pre><code>#include &lt;iostream&gt; void f(unsigned long){ std::cout &lt;&lt; "unsigned long\n"; } void f(long long) { std::cout &lt;&lt; "long long\n"; } void f(unsigned long long) { std::cout &lt;&lt; "unsigned long long\n"; } void f(unsigned) { std::cout &lt;&lt; "unsigned int\n"; } int main(){ f(4294967295); f(4294967296); f(0xffffffff); f(0x100000000); } </code></pre> <p>Result with VC++ 2008 and VC++ 2013 RC:</p> <pre><code>unsigned long long long unsigned int long long </code></pre> <p>I don't have all the intervening versions installed, but given that 2008 and 2013 match, I think it's fair to guess that versions in between them act the same way as well.</p>
 

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