Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following is how standard (ISO 14882) explains abort -1 > sizeof(int)</p> <p>Relational operator `>' is defined in 5.9 (expr.rel/2)</p> <blockquote> <p>The usual arithmetic conversions are performed on operands of arithmetic or enumeration type. ...</p> </blockquote> <p>The usual arithmetic conversions is defined in 5 (expr/9)</p> <p>... The pattern is called the usual arithmetic conversions, which are defined as following:</p> <ul> <li>If either operand is of type long double, ...</li> <li>Otherwise, if either operand is dobule, ...</li> <li>Otherwise, if either operand is float, ...</li> <li>Otherwise, the integral promotions shall be performed on both operands.</li> <li>...</li> </ul> <p>The integral promotions is defined in 4.5 (conv.prom/1)</p> <blockquote> <p>An rvalue of type char, signed char, unsigned char, short int, or unsigned short int can be converted to an rvalue of type int if int can represent all the values of the source type; otherwise, the source rvalue can be converted to an rvalue of type unsigned int.</p> </blockquote> <p>The result of sizeof is defined in 5.3.3 (expr.sizeof/6)</p> <blockquote> <p>The result is a constant of type size_t</p> </blockquote> <p>size_t is defined in C standard (ISO 9899), which is <strong>unsigned integer type</strong>.</p> <p>So for <code>-1 &gt; sizeof(int)</code>, the > triggers usual arithmetic conversions. The usual arithmetic conversion converts -1 to unsigned int because int cannot represent all the value of <code>size_t</code>. <code>-1</code> becomes a very large number depend on platform. So <code>-1 &gt; sizeof(int)</code> is <code>true</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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