Problems compiling on macOS 10.13.4: (some destructor) has a non-throwing exception specification but can still throw [-Werror,-Wexceptions]
Hi
It is most likely a user error.
$ c++ --version Apple LLVM version 9.1.0 (clang-902.0.39.1) Target: x86_64-apple-darwin17.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
fdbclient/MultiVersionAssignmentVars.h:135:2: note: destructor has a implicit non-throwing exception specification ~DLThreadSingleAssignmentVar() { ^ fdbclient/MultiVersionAssignmentVars.h:138:4: error: '~DLThreadSingleAssignmentVar' has a non-throwing exception specification but can still throw [-Werror,-Wexceptions] ASSERT(futureRefCount == 1); ^ ./flow/Error.h:84:81: note: expanded from macro 'ASSERT' #define ASSERT( condition ) if (!((condition) || isAssertDisabled(LINE))) { throw internal_error(); }
I can work around it by adding noexcept(false) to the destructors, but is there a better way?
I was working on master. Tried 5.1 branch but still having this issue. Also use boost 1.52 as noted in README as newer version is breaking some stuff.
Is there some build flags that are missing in the instructions for mac?
I changed "throw internal_error();" to "assert(0)" to get around this for now. I think this an incompatibility with the latest clang where this used to be a warning and is now an error.
There is a macro ASSERT_ABORT( ) defined in Error.h right next to ASSERT and intended for use in this scenario. It is important to still call internal_error() since that does a lot of useful logging.
How do you propose fixing this @davidscherer?
Simply replacing usages of ASSERT in destructors with ASSERT_ABORT should resolve the issue, I would think. It still calls the internal error logic that generates debug logging, but then calls abort() rather than throwing an exception.
Oh shoot. I have a patch to fix this which I forgot to push. I'll post a PR on Monday for it.
Since I'm looking at this code for the first time in probably close to a decade, maybe ASSERT_ABORT should actually call flushAndExit() or criticalError() from platform.h rather than abort() from the C library?
#237 was merged