When running the scoped_allocator test with -O3 on my mac, I get the stated assertion. My g++ appears to be clang++ masquerading as g++, version as follows:
$ g++ --version
Configured with: --prefix=/Applications/Xcode_9.3.0_fb.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode_9.3.0_fb.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin