[CoinUtils] Bug or no bug? (VS2010 & null pointers)

Matthew Galati matthew.galati at gmail.com
Thu Mar 10 07:17:37 EST 2011


Looks like a coin bug to me. You should check for null ptr before
using std equal inside your operator. You can't rely on the stl
implementation for that.


On 3/9/11, Lou Hafer <lou at cs.sfu.ca> wrote:
> Folks,
>
>      Those of you on the last TLC telecon will recall I mentioned that
> the CoinUtils unit test triggers a VS assert when built in debug mode in
> VS2010. Here are the details. The question: Is this our bug, or a bug in
> MS's debug library.
>
>      A CoinShallowPackedVector object contains pointers to vectors of
> elements and coefficients. The default constructor sets these attributes
> to 0. CoinShallowPackedVector::operator== contains the following call:
>
>   std::equal(getIndices(), getIndices()+getNumElements(), rhs.getIndices())
>
> For an empty vector, this will resolve to std::equal(0,0+0,0). Some
> sample code is attached that will trigger the assert in a debug build
> and run just fine in a release build. I'll point out that VS2010 is the
> firstplatform I know of that has this problem.
>
>      The VS debug libraries contain lots of useful code to catch errors,
> so I'm reluctant to bludgeon VS into submission by defining compile-time
> symbols to remove the checks. I was just going to just report this as a
> VS bug, but it's arguable. (As a technical defense, the MS documentation
> does state that all pointers must be dereferenceable.) So I'm putting it
> out to the community. Opinions? Is this our bug, or Microsoft's bug?
>
>
>                    Lou
>

-- 
Sent from my mobile device



More information about the CoinUtils mailing list