[test] BOOST_CHECK_EQUAL comparisons with NULL don't compile
This use case seems really common and I was surprised it gave me problems.
I assume that nullptr_t in C++11 fixes this but then I was wondering
if the cases were basic and common enough it would make sense to have
a BOOST_CHECK_NULL / BOOST_CHECK_NOT_NULL and the assorted variants.
james
---
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Hello
#include
On Fri, Sep 7, 2012 at 11:32 AM, James Mathiesen
This use case seems really common and I was surprised it gave me problems.
I assume that nullptr_t in C++11 fixes this but then I was wondering if the cases were basic and common enough it would make sense to have a BOOST_CHECK_NULL / BOOST_CHECK_NOT_NULL and the assorted variants.
Use "0" instead of NULL. -- Chris Cleeland
AMDG On 09/07/2012 10:35 AM, Chris Cleeland wrote:
On Fri, Sep 7, 2012 at 11:32 AM, James Mathiesen
wrote: This use case seems really common and I was surprised it gave me problems.
I assume that nullptr_t in C++11 fixes this but then I was wondering if the cases were basic and common enough it would make sense to have a BOOST_CHECK_NULL / BOOST_CHECK_NOT_NULL and the assorted variants.
Use "0" instead of NULL.
This won't help given that the cause of the problem is that NULL *is* 0. In Christ, Steven Watanabe
[Please do not mail me a copy of your followup]
boost-users@lists.boost.org spake the secret code
BOOST_CHECK_EQUAL(ptr, NULL);
BOOST_CHECK(!ptr); But in general, yes, NULL is problematic for a number of reasons and that is why C++11 introduced the nullptr keyword. C++ prior to that had advocated the use of the constant 0 instead of NULL (NULL was, after all, a C-ism that C++ inherited), but in certain template constructs even that wasn't distinguishing enough between "the pointer to nothing" and "integer constant". -- "The Direct3D Graphics Pipeline" free book http://tinyurl.com/d3d-pipeline The Computer Graphics Museum http://computergraphicsmuseum.org The Terminals Wiki http://terminals.classiccmp.org Legalize Adulthood! (my blog) http://legalizeadulthood.wordpress.com
participants (4)
-
Chris Cleeland
-
James Mathiesen
-
legalize+jeeves@mail.xmission.com
-
Steven Watanabe