foundationdb icon indicating copy to clipboard operation
foundationdb copied to clipboard

Problems compiling on macOS 10.13.4: (some destructor) has a non-throwing exception specification but can still throw [-Werror,-Wexceptions]

Open schafdog opened this issue 8 years ago • 8 comments

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?

schafdog avatar Apr 20 '18 12:04 schafdog

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?

schafdog avatar Apr 21 '18 06:04 schafdog

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.

spullara avatar Apr 22 '18 00:04 spullara

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.

davidscherer avatar Apr 22 '18 18:04 davidscherer

How do you propose fixing this @davidscherer?

josephg avatar Apr 22 '18 22:04 josephg

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.

ajbeamon avatar Apr 22 '18 22:04 ajbeamon

Oh shoot. I have a patch to fix this which I forgot to push. I'll post a PR on Monday for it.

alexmiller-apple avatar Apr 23 '18 00:04 alexmiller-apple

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?

davidscherer avatar Apr 23 '18 00:04 davidscherer

#237 was merged

alexmiller-apple avatar Apr 23 '18 21:04 alexmiller-apple