ISO/ IEC JTC1/SC22/WG14 N723


ISO/IEC JTC1/SC22/WG14 N723

                    Changes to shift operators
                          Clive D.W. Feather


Abstract
========

This paper addresses the issues related to shift operators that were
removed from N691.

The proposal only substantively affects the << operator; the result
is defined if E1 is nonnegative and the shift does not reach the sign
bit, and is undefined otherwise.


Proposal
========

Modify subclause 6.3.7 (the << and >> operators) as follows:

* In paragraph 3, change "the width in bits" to "the number of value and
sign bits in the object representation".

* Add to the end of paragraph 4 (the << paragraph):

    If E1 has a signed type and nonnegative value, and E1 times 2 to
    the power E2 is less than or equal to /INT_MAX/ (if E1 has type
    /int/), /LONG_MAX/ (if E1 has type /long int/), or LLONG_MAX (if
    E1 has type /long long int/), then that is the resulting value.
    Otherwise the behavior is undefined.