Expensive checks build broken

I noticed that the expensive checks build
(-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON) is broken (log below). It looks
like __glibcxx_requires_valid_range in libstdc++ (in debug mode) is not
constexpr.

Is this a known issue? Working around this would seem to be pretty
invasive. Should this be considered a libstdc++ bug? This is g++
8.1.0.

                        -David

--8<-----------------------------------------------------------------------

FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o
g++ -DEXPENSIVE_CHECKS -D_DEBUG -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/src/llvm-project/llvm/lib/Support -I/usr/include/libxml2 -Iinclude -I/src/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++14 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -g -fPIC -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o -c /src/llvm-project/llvm/lib/Support/SourceMgr.cpp
In file included from /opt/gcc/8.1.0/snos/include/g++/algorithm:62,
                 from /src/llvm-project/llvm/include/llvm/Support/MathExtras.h:18,
                 from /src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19,
                 from /src/llvm-project/llvm/include/llvm/ADT/STLExtras.h:20,
                 from /src/llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                 from /src/llvm-project/llvm/include/llvm/ADT/StringMap.h:16,
                 from /src/llvm-project/llvm/include/llvm/Support/Host.h:16,
                 from /src/llvm-project/llvm/include/llvm/ADT/Hashing.h:48,
                 from /src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12,
                 from /src/llvm-project/llvm/include/llvm/Support/SourceMgr.h:18,
                 from /src/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h: In instantiation of 'constexpr const int llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*>::NumLowBitsAvailable':
/src/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:144:48: required from 'struct llvm::PointerIntPairInfo<void*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*> >'
/src/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:71:32: required from 'void llvm::PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>::initWithPointer(PointerTy) [with PointerTy = void*; unsigned int IntBits = 2; IntType = int; PtrTraits = llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*>; Info = llvm::PointerIntPairInfo<void*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*> >]'
/src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:227:5: required from 'const llvm::PointerUnion<PTs>& llvm::PointerUnion<PTs>::operator=(std::nullptr_t) [with PTs = {std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*}; std::nullptr_t = std::nullptr_t]'
/src/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:23: required from here
/src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:93:72: in 'constexpr' expansion of 'llvm::pointer_union_detail::lowBitsAvailable<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*>()'
/src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:64:25: in 'constexpr' expansion of 'std::min<int>(std::initializer_list<int>{((const int*)(& const int [4]{3, 3, 3, 3})), 4})'
/opt/gcc/8.1.0/snos/include/g++/bits/stl_algo.h:3451:31: error: 'constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = const int*]' called in a constant expression
     { return *std::min_element(__l.begin(), __l.end()); }
               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/opt/gcc/8.1.0/snos/include/g++/bits/stl_algo.h:5610:12: note: 'constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = const int*]' is not usable as a 'constexpr' function because:
     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
            ^~~~~~~~~~~
In file included from /opt/gcc/8.1.0/snos/include/g++/debug/debug.h:84,
                 from /opt/gcc/8.1.0/snos/include/g++/bits/stl_algobase.h:69,
                 from /opt/gcc/8.1.0/snos/include/g++/memory:62,
                 from /src/llvm-project/llvm/include/llvm/ADT/Optional.h:22,
                 from /src/llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                 from /src/llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                 from /src/llvm-project/llvm/include/llvm/ADT/StringMap.h:16,
                 from /src/llvm-project/llvm/include/llvm/Support/Host.h:16,
                 from /src/llvm-project/llvm/include/llvm/ADT/Hashing.h:48,
                 from /src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12,
                 from /src/llvm-project/llvm/include/llvm/Support/SourceMgr.h:18,
                 from /src/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/opt/gcc/8.1.0/snos/include/g++/bits/stl_algo.h:5616:7: error: call to non-'constexpr' function 'bool __gnu_debug::__valid_range(const _InputIterator&, const _InputIterator&) [with _InputIterator = const int*]'
       __glibcxx_requires_valid_range(__first, __last);
       ^
In file included from /src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18,
                 from /src/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20,
                 from /src/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/src/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h: In instantiation of 'struct llvm::PointerIntPairInfo<void*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*> >':
/src/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:71:32: required from 'void llvm::PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>::initWithPointer(PointerTy) [with PointerTy = void*; unsigned int IntBits = 2; IntType = int; PtrTraits = llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*>; Info = llvm::PointerIntPairInfo<void*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*> >]'
/src/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:227:5: required from 'const llvm::PointerUnion<PTs>& llvm::PointerUnion<PTs>::operator=(std::nullptr_t) [with PTs = {std::__debug::vector<unsigned char, std::allocator<unsigned char> >*, std::__debug::vector<short unsigned int, std::allocator<short unsigned int> >*, std::__debug::vector<unsigned int, std::allocator<unsigned int> >*, std::__debug::vector<long unsigned int, std::allocator<long unsigned int> >*}; std::nullptr_t = std::nullptr_t]'
/src/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:23: required from here
/src/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:149:8: error: enumerator value for 'IntShift' is not an integer constant
   enum : uintptr_t {
        ^

This was raised before in the "SourceMgr vs EXPENSIVE_CHECKS" thread
(http://llvm.1065342.n5.nabble.com/llvm-dev-SourceMgr-vs-EXPENSIVE-CHECKS-td130895.html)