Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As far as C++ is concerned:</p> <p>C++11, [lex.icon] ¶2</p> <blockquote> <p>The type of an integer literal is the first of the corresponding list in Table 6 in which its value can be represented.</p> </blockquote> <p>And Table 6, for literals without suffixes and decimal constants, gives:</p> <pre><code>int long int long long int </code></pre> <p>(interestingly, for hexadecimal or octal constants also <code>unsigned</code> types are allowed - but each one come <em>after</em> the corresponding signed one in the list)</p> <p>So, it's clear that in that case the constant has been interpreted as a <code>long int</code> (or <code>long long int</code> if <code>long int</code> was too 32 bit).</p> <p>Notice that "too big literals" should result in a compilation error:</p> <blockquote> <p>A program is ill-formed if one of its translation units contains an integer literal that cannot be represented by any of the allowed types.</p> </blockquote> <p>(ibidem, ¶3)</p> <p>which is promptly seen <a href="http://ideone.com/9hujM">in this sample</a>, that reminds us that ideone.com uses 32 bit compilers.</p> <hr /> <p>I saw now that the question was about C... well, it's more or less the same:</p> <p>C99, §6.4.4.1</p> <blockquote> <p>The type of an integer constant is the first of the corresponding list in which its value can be represented.</p> </blockquote> <p>list that is the same as in the C++ standard.</p> <hr /> <p>Addendum: both C99 and C++11 allow also the literals to be of "extended integer types" (i.e. other implementation-specific integer types) if everything else fails. (C++11, [lex.icon] ¶3; C99, §6.4.4.1 ¶5 after the table)</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