Created On:  15 June 2011


vector example:

When running the code snippet above, DevPartner will show the following error message:

Unrelated Pointer: Comparing two unrelated pointers 0x082862B4 and 0x003BF9C4. Pointers are not within the same buffer.

The error occurs only occurs on Visual Studio 2010, it is not seen on Visual Studio 2008.


This can be treated as a false positive at the moment and can be suppressed from the error dialog.

When calling “push_back” method for the std::vector, it calls a function “_Inside” implemented by Visual Studio 2010.

                bool _Inside(const _Ty *_Ptr) const
                                {               // test if _Ptr points inside vector
                                return (_Ptr < this->_Mylast && this->_Myfirst <= _Ptr);

From C standard, when comparing pointers the result from equality operators (== and !=) are specified, but the ordering operators (<, <=, >, >=) are unspecified.

While the function will get some kind of result (either true or false) and the function does not crash from using the ordering operators (<, <=, >, >=). It is still unspecified, equivalent to an undefined behavior. Hence it is marked as a potential defect. This is why the error message is displayed during program execution.
Incident #2517544