<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 7, 2016 at 2:28 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
   We have code<br>
<br>
  return (BT_idx        = index/PETSC_BITS_PER_BYTE,<br>
          BT_c          = array[BT_idx],<br>
          BT_mask       = (char)(1 << index%PETSC_BITS_PER_BYTE),<br>
          array[BT_idx] = (char)(BT_c | BT_mask),<br>
          (char)(BT_c & BT_mask));<br>
<br>
inside<br>
<br>
petscbt.h<br>
<br>
the clang static code analyzer reports<br>
<br>
In file included from /sandbox/petsc/petsc.clone/include/petsc/private/matimpl.h:1233:<br>
/sandbox/petsc/petsc.clone/include/petscbt.h:85:36: warning: The result of the '<<' expression is undefined<br>
          BT_mask       = (char)(1 << index%PETSC_BITS_PER_BYTE),<br>
                                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>
Is the code wrong/unnecessary or clang?<br></blockquote><div><br></div><div>It looks right to me:</div><div><br></div><div>  index%PETSC_BITS_PER_BYTE<br></div><div><br></div><div>gives the offset of this bit in the current byte.</div><div><br></div><div>  1 << index%PETSC_BITS_PER_BYTE</div><div><br></div><div>Gives an int with a 1 at the offset'th bit, and then</div><div>we cast to a char.</div><div><br></div><div>I have no idea why clang complains.</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
   Thanks<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>