title: compiler warning: left shift of negative value
body: <p>I think GCC is wrongfully producing a [-Wshift-negative-value] warning.</p>
  
  <p>I have a function that should produce a suffix mask of a certain length provided by its single input argument:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  
  uint16_t get_suffix_mask_sht(uint8_t shift) {
      return (~(~((uint16_t) 0) &lt;&lt; shift));
  }
  </code></pre>
  
  <p>I have tried to compile this function with the following compiler options on different versions of gcc</p>
  
  <pre><code>-Werror -Wextra
  </code></pre>
  
  <p>This warning also occurs if I change the output from <code>uint16_t</code> to <code>uint8_t</code>. Bigger output types, i.e. <code>uint32_t</code> don't produce this warning.</p>
  
  <p>I am using an older version of GCC: 7.4. But I have tried this out on <a href="https://godbolt.org/" rel="nofollow noreferrer">godbolt</a> using the latest GCC 9.x versions and they all produce the same warning. Clang versions however do not produce this error.</p>