Compilation Error: 'this' pointer cannot be null in well-defined C++ code;

Description

When compiling on OSX, with the following version of clang:

➜ HPCCSystems clang --version
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

I receive the following errors:

In file included from /Users/bone/git/boneill42/hpcc/system/jlib/jhash.hpp:28:
/Users/bone/git/boneill42/hpcc/system/jlib/jsuperhash.hpp:458:46: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
operator const char * () { return (NULL==this)?NULL:keyPtr(); }
~~~~ ^~~~
...

In file included from /Users/bone/git/boneill42/hpcc/system/jlib/jlib.hpp:194:
/Users/bone/git/boneill42/hpcc/system/jlib/jhash.hpp:66:58: error: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Werror,-Wundefined-bool-conversion]
const char * getAtomNamePtr() const { return this ? getNamePtr() : NULL; }
^~~~ ~
2 errors generated.
make[2]: *** [system/jlib/CMakeFiles/jlib.dir/jargv.cpp.o] Error 1
make[1]: *** [system/jlib/CMakeFiles/jlib.dir/all] Error 2

Conclusion

None

Activity

Show:

Richard Chapman July 13, 2015 at 10:21 AM

Richard Chapman July 3, 2015 at 4:14 PM

Full fix (rather than just suppressing the warning) is now applied.

Richard Chapman May 19, 2015 at 9:29 AM

Gavin Halliday May 11, 2015 at 9:34 AM

We agree it is an issue that needs to be solved. Our conclusions were

  • 5.2.x Add a pragma to temporarily disable the warnings

  • 5.4.x Add any necessary functions to call in place of the invalid member functions. Any new code should use these new functions (to ensure merging to 6.x doesn't cause issues).

  • 6.0.x Remove the invalid member functions.

We should also ensure that reference parameters are never used for values that can be NULL.

Brian O'Neill May 4, 2015 at 5:13 PM

Fixed with a few pragma statements:

e.g.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-undefined-compare"

I'll submit a PR for this, and you can decide if you want to pull it in.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Components

Assignee

Reporter

Priority

Fix versions

Created May 4, 2015 at 5:05 PM
Updated July 13, 2015 at 10:21 AM
Resolved July 3, 2015 at 4:14 PM