[petsc-dev] technical C question

Barry Smith bsmith at mcs.anl.gov
Thu Apr 7 15:38:40 CDT 2016


> On Apr 7, 2016, at 2:37 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> Barry Smith <bsmith at mcs.anl.gov> writes:
>> 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?
> 
> I would guess it is complaining about C99 §6.5.7.3:
> 
>  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.

   Should we caste to an unsigned PetscInt first then?





More information about the petsc-dev mailing list