Project

General

Profile

« Previous | Next » 

Revision 87784fde

Added by peterzhu2118 (Peter Zhu) over 3 years ago

Keep right operand within width when right shifting

NUM_IN_PAGE could return a value much larger than 64. According to the
C11 spec 6.5.7 paragraph 3 this is undefined behavior:

If the value of the right operand is negative or is greater than or
equal to the width of the promoted left operand, the behavior is
undefined.

On most platforms, this is usually not a problem as the architecture
will mask off all out-of-range bits.