You are looking at the code that I fixed yesterday, see my commit message for details here: http://lists.blender.org/pipermail/bf-blender-cvs/2012-April/045090.html
>>V610 Undefined behavior. Check the shift operator '<<. The left operand '(~0)' is negative. extern_bullet btquantizedbvh.h 82 ~(0) is signed -1, negative, while ~(x&0) is positive unsigned, so it fixes the undefined behavior. Thanks, Erwin On 24 April 2012 18:01, Jason Wilkins <[email protected]> wrote: > This line in btQuantizedBvh.h confuses me: > > int getTriangleIndex() const > { > btAssert(isLeafNode()); > unsigned int x=0; > unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS); > // Get only the lower bits where the triangle index is > stored > return (m_escapeIndexOrTriangleIndex&~(y)); > } > > Ostensibly the error is that ~0 is -1 (unsigned) and shifting an > unsigned is undefined or unspecified (forget which). > > But I'm actually confused why this code is written this way. > x=0, then x&0 == 0, even if x wasn't 0. > > Only after that do we get to the undefined behavior. > > I guess I could puzzle through it, but somebody else might just know :-) > > On Tue, Apr 24, 2012 at 7:30 PM, Jason Wilkins > <[email protected]> wrote: > > I'm working through them and fixing what Clang did not catch. > > > > I was going to say the same thing as Nicholas, code analysis is such a > > wide open field with virtually infinite number of things you can check > > for, that having more than one tool is a good idea. > > > > On Tue, Apr 24, 2012 at 6:30 PM, Nicholas Bishop > > <[email protected]> wrote: > >> Not necessarily; different static analyzers can detect different types > >> of potential problems. The PVS analysis contains some interesting > >> things like the "Misprint in a homogeneous code block" section that I > >> don't think clang's analyzer does. > >> > >> On Tue, Apr 24, 2012 at 7:20 PM, Tom M <[email protected]> wrote: > >>> We have a page with generated CLang static analysis, > >>> > >>> http://clang.blenderheads.org/trunk/ > >>> > >>> It probably shows the same bugs as PVS-Studio does. > >>> > >>> LetterRip > >>> > >>> On Tue, Apr 24, 2012 at 4:15 PM, Nicholas Bishop > >>> <[email protected]> wrote: > >>>> I think some of these have been fixed already in recent commits from > Campbell. > >>>> > >>>> On Tue, Apr 24, 2012 at 7:11 PM, Jason Wilkins > >>>> <[email protected]> wrote: > >>>>> http://www.viva64.com/en/b/0145/#ID0EO3BK > >>>>> > >>>>> It appears that Andrey Karpov has done an analysis of Blender source > >>>>> code using his PVS-Studio tool. He did this just yesterday, so I > >>>>> assume the problems he found are still in the source. He offers free > >>>>> licenses to open source project members (3500 euro software > otherwise, > >>>>> wow). > >>>>> > >>>>> I was thinking of investigating the problems he found and seeing if I > >>>>> could fix them. > >>>>> _______________________________________________ > >>>>> Bf-committers mailing list > >>>>> [email protected] > >>>>> http://lists.blender.org/mailman/listinfo/bf-committers > >>>> _______________________________________________ > >>>> Bf-committers mailing list > >>>> [email protected] > >>>> http://lists.blender.org/mailman/listinfo/bf-committers > >>> _______________________________________________ > >>> Bf-committers mailing list > >>> [email protected] > >>> http://lists.blender.org/mailman/listinfo/bf-committers > >> _______________________________________________ > >> Bf-committers mailing list > >> [email protected] > >> http://lists.blender.org/mailman/listinfo/bf-committers > _______________________________________________ > Bf-committers mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-committers > _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
