[petsc-dev] technical C question

Barry Smith bsmith at mcs.anl.gov
Thu Apr 7 14:28:42 CDT 2016

   We have code 

  return (BT_idx        = index/PETSC_BITS_PER_BYTE,
          BT_c          = array[BT_idx],
          BT_mask       = (char)(1 << index%PETSC_BITS_PER_BYTE),
          array[BT_idx] = (char)(BT_c | BT_mask),
          (char)(BT_c & BT_mask));



the clang static code analyzer reports 

In file included from /sandbox/petsc/petsc.clone/include/petsc/private/matimpl.h:1233:
/sandbox/petsc/petsc.clone/include/petscbt.h:85:36: warning: The result of the '<<' expression is undefined
          BT_mask       = (char)(1 << index%PETSC_BITS_PER_BYTE),

Is the code wrong/unnecessary or clang?


More information about the petsc-dev mailing list