- 
                Notifications
    You must be signed in to change notification settings 
- Fork 535
Description
When using a newer C++ compiler, we're seeing an issue with using CHECK_EQUAL and a NULL pointer value.
Specifically, I have a check like this:
CHECK_EQUAL(NULL, actual);
When we compile using clang 4, we have no issues, but when updating to clang 6, we see the following compilation issue:
test.cpp:89:2: error: call to 'StringFrom' is ambiguous
        CHECK_EQUAL(NULL, actual);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/CppUTest/UtestMacros.h:127:3: note: expanded from macro 'CHECK_EQUAL'
  CHECK_EQUAL_LOCATION(expected, actual, NULL, __FILE__, __LINE__)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/CppUTest/UtestMacros.h:138:52: note: expanded from macro 'CHECK_EQUAL_LOCATION'
      UtestShell::getCurrent()->assertEquals(true, StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), text, file, line); \
                                                   ^~~~~~~~~~
/usr/local/include/CppUTest/SimpleString.h:138:14: note: candidate function
SimpleString StringFrom(const void* value);
             ^
/usr/local/include/CppUTest/SimpleString.h:139:14: note: candidate function
SimpleString StringFrom(void (*value)());
             ^
/usr/local/include/CppUTest/SimpleString.h:141:14: note: candidate function
SimpleString StringFrom(const char *value);
             ^
/usr/local/include/CppUTest/SimpleString.h:137:14: note: candidate function
SimpleString StringFrom(bool value);
             ^
/usr/local/include/CppUTest/SimpleString.h:157:14: note: candidate function
SimpleString StringFrom(const SimpleString& other);
             ^
/usr/local/include/CppUTest/SimpleString.h:171:14: note: candidate function
SimpleString StringFrom(const std::string& other);This appears, I believe, because of how StringFrom in the SimpleString.h header doesn't have a strict equivalent StringFrom(nullptr_t), so it's ambiguous which function it could actually be used with.
I believe when building using clang4, that NULL is not considered a nullptr type but just zero.
I suspect the fix is rather straight forward, and just provide a StringFrom(nullptr_t) if we're building on C++ 11 or newer....
We can work around this in our test code by type-casting the NULL to something specific, but this is rather annoying.