Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The informations on the left shift operator in C99 draft standard (ISO/IEC9899:TC3, aka WG14/N1256) are rather scant.</p> <p>Section 6.5.7 (bitwise shift operators) has already been cited by Alter Mann. </p> <p>Annex J, section J.2 (Undefined behavior) says the following:</p> <blockquote> <p>The behavior is undefined in the following circumstances:<br/> [...]</p> <p>— An expression is shifted by a negative number or by an amount greater than or equal to the width of the promoted expression (6.5.7).</p> <p>— An expression having signed promoted type is left-shifted and either the value of the expression is negative or the result of shifting would be not be representable in the promoted type (6.5.7).</p> </blockquote> <p>I don't think it is allowed for a conforming implementation to make some mandatory undefined behavior defined. If I'm not mistaken an implementation is allowed to define <strong>unspecified behavior</strong> (but it is not required to) and is required to specify <strong>implementation defined behavior</strong>, but undefined behavior cannot be <em>specified</em>. This doesn't mean that an implementation cannot choose a <em>sane meaningful behavior</em>, but it cannot let the user rely on that (it cannot "specify it").</p> <p>I admit I'm not completely sure of that. Hope this helps.</p> <p><strong>Edit:</strong> Upon further reflection I think a conforming implementation <em>can specify</em> a behavior for what the standard deems <strong>undefined behavior</strong>, but the resulting program cannot be called conforming (see section 3.4.3).</p>
    singulars
    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. 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.
 

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