SourceMgr vs EXPENSIVE_CHECKS

Hi,

I'm trying to build llvm (git monorepo) on Ubuntu 18.04 with
EXPENSIVE_CHECKS enabled and running into various errors compiling
SourceMgr.cpp, depending on which host compiler I use.

For example with GCC:

$ CC=gcc-8 CXX=g++-8 cmake -GNinja -DCMAKE_BUILD_TYPE=Debug
-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON ~/git/llvm-project/llvm/ && ninja
...
[89/2690] Building CXX object
lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o
/usr/lib/ccache/g++-8 -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -D_DEBUG
-D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support
-I/home/jayfoad2/git/llvm-project/llvm/lib/Support -Iinclude
-I/home/jayfoad2/git/llvm-project/llvm/incl
ude -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 -fno-exceptions -fno-rtti -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
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp
In file included from /usr/include/c++/8/algorithm:62,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/MathExtras.h:18,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:20,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/StringMap.h:16,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/Host.h:16,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/Hashing.h:48,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:18,
                 from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/home/jayfoad2/git/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

>*>::NumLowBitsAvailable’:

/home/jayfoad2/git/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

>*> >’

/home/jayfoad2/git/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

>*>; 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

>*> >]’

/home/jayfoad2/git/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

>*, std::__debug::vector<unsigned int, std::allocator<unsigned
>*, std::__debug::vector<long unsigned int, std::allocator<long

unsigned int> >*}; std::nullptr_t = std::nullptr_t]’
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:23:
  required from here
/home/jayfoad2/git/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

>*>()’

/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:64:25:
  in ‘constexpr’ expansion of
‘std::min<int>(std::initializer_list<int>{((const int*)(& ._125)),
4})’
/usr/include/c++/8/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()); }
               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/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 /usr/include/c++/8/debug/debug.h:84,
                 from /usr/include/c++/8/bits/stl_algobase.h:69,
                 from /usr/include/c++/8/memory:62,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/Optional.h:22,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:19,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/StringRef.h:12,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/StringMap.h:16,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/Host.h:16,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/Hashing.h:48,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:18,
                 from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/usr/include/c++/8/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
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18,
                 from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20,
                 from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
/home/jayfoad2/git/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

>*> >’:

/home/jayfoad2/git/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

>*>; 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

>*> >]’

/home/jayfoad2/git/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

>*, std::__debug::vector<unsigned int, std::allocator<unsigned
>*, std::__debug::vector<long unsigned int, std::allocator<long

unsigned int> >*}; std::nullptr_t = std::nullptr_t]’
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:23:
  required from here
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:149:8:
error: enumerator value for ‘IntShift’ is not an integer constant
   enum : uintptr_t {
        ^

For example with Clang:

$ CC=clang-7 CXX=clang++-7 cmake -GNinja -DCMAKE_BUILD_TYPE=Debug
-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON ~/git/llvm-project/llvm/ && ninja
[...]
[91/2690] Building CXX object
lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o
/usr/bin/clang++-7 -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -D_DEBUG
-D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support
-I/home/jayfoad2/git/llvm-project/llvm/lib/Support -Iinclude
-I/home/jayfoad2/git/llvm-project/llvm/include -fPIC
-fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -std=c++14 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion
-fdiagnostics-color -g -fno-exceptions -fno-rtti -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
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:93:26:
error: constexpr variable 'NumLowBitsAvailable' must be initialized by
a constant expression
    static constexpr int NumLowBitsAvailable = lowBitsAvailable<PTs...>();
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:144:17:
note: in instantiation of template class
'llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>' requested here
  static_assert(PtrTraits::NumLowBitsAvailable <
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:71:13:
note: in instantiation of template class
'llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

' requested here

    Value = Info::updatePointer(0, PtrVal);
            ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:227:15:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::initWithPointer' requested here

    this->Val.initWithPointer(nullptr);
              ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:21:
note: in instantiation of member function
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::operator=' requested here
  Other.OffsetCache = nullptr;
                    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_algo.h:5616:7:
note: non-constexpr function '__valid_range<const int *>' cannot be
used in a constant expression
      __glibcxx_requires_valid_range(__first, __last);
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/debug/debug.h:88:3:
note: expanded from macro '__glibcxx_requires_valid_range'
  __glibcxx_check_valid_range(_First,_Last)
  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/debug/macros.h:54:23:
note: expanded from macro '__glibcxx_check_valid_range'
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
                      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_algo.h:3451:15:
note: in call to 'min_element(&{PointerLikeTypeTraits<vector<unsigned
char, allocator<unsigned char> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned short, allocator<unsigned short>

*>::NumLowBitsAvailable, PointerLikeTypeTraits<vector<unsigned int,

allocator<unsigned int> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned long, allocator<unsigned long> >
*>::NumLowBitsAvailable}[0], &{PointerLikeTypeTraits<vector<unsigned
char, allocator<unsigned char> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned short, allocator<unsigned short>

*>::NumLowBitsAvailable, PointerLikeTypeTraits<vector<unsigned int,

allocator<unsigned int> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned long, allocator<unsigned long> >
*>::NumLowBitsAvailable}[4])'
    { return *std::min_element(__l.begin(), __l.end()); }
              ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:64:12:
note: in call to 'min({&{PointerLikeTypeTraits<vector<unsigned char,
allocator<unsigned char> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned short, allocator<unsigned short>

*>::NumLowBitsAvailable, PointerLikeTypeTraits<vector<unsigned int,

allocator<unsigned int> > *>::NumLowBitsAvailable,
PointerLikeTypeTraits<vector<unsigned long, allocator<unsigned long> >
*>::NumLowBitsAvailable}[0], 4})'
    return std::min<int>({PointerLikeTypeTraits<Ts>::NumLowBitsAvailable...});
           ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:93:48:
note: in call to 'lowBitsAvailable()'
    static constexpr int NumLowBitsAvailable = lowBitsAvailable<PTs...>();
                                               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/debug/helper_functions.h:161:5:
note: declared here
    __valid_range(const _InputIterator& __first, const _InputIterator& __last)
    ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:144:17:
error: static_assert expression is not an integral constant expression
  static_assert(PtrTraits::NumLowBitsAvailable <
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:71:13:
note: in instantiation of template class
'llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

' requested here

    Value = Info::updatePointer(0, PtrVal);
            ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:227:15:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::initWithPointer' requested here

    this->Val.initWithPointer(nullptr);
              ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:21:
note: in instantiation of member function
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::operator=' requested here
  Other.OffsetCache = nullptr;
                    ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:144:17:
note: initializer of 'NumLowBitsAvailable' is not a constant
expression
  static_assert(PtrTraits::NumLowBitsAvailable <
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:93:26:
note: declared here
    static constexpr int NumLowBitsAvailable = lowBitsAvailable<PTs...>();
                         ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:71:17:
error: incomplete definition of type 'llvm::PointerIntPairInfo<void *,
2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

'

    Value = Info::updatePointer(0, PtrVal);
            ~~~~^~
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:227:15:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::initWithPointer' requested here

    this->Val.initWithPointer(nullptr);
              ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:107:21:
note: in instantiation of member function
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::operator=' requested here
  Other.OffsetCache = nullptr;
                    ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:58:47:
error: no member named 'getPointer' in 'llvm::PointerIntPairInfo<void
*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

'

  PointerTy getPointer() const { return Info::getPointer(Value); }
                                              ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:179:43:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::getPointer' requested here

  bool isNull() const { return !this->Val.getPointer(); }
                                          ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:111:20:
note: in instantiation of member function
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::isNull' requested here
  if (!OffsetCache.isNull()) {
                   ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:60:50:
error: no member named 'getInt' in 'llvm::PointerIntPairInfo<void *,
2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

'

  IntType getInt() const { return (IntType)Info::getInt(Value); }
                                                 ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:188:22:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::getInt' requested here

    return this->Val.getInt() == Index;
                     ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:112:21:
note: in instantiation of function template specialization
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::is<std::__debug::vector<unsigned char, std::allocator<unsigned

> *>' requested here

    if (OffsetCache.is<std::vector<uint8_t>*>())
                    ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:195:12:
error: no matching member function for call to 'is'
    assert(is<T>() && "Invalid accessor called");
           ^~~~~
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr) \
                          ^~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:115:26:
note: in instantiation of function template specialization
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::get<std::__debug::vector<unsigned short, std::allocator<unsigned

> *>' requested here

      delete OffsetCache.get<std::vector<uint16_t>*>();
                         ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:184:29:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned short, std::allocator<unsigned short> >
*]
  template <typename T> int is() const {
                            ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:195:12:
error: no matching member function for call to 'is'
    assert(is<T>() && "Invalid accessor called");
           ^~~~~
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
     (static_cast <bool> (expr) \
                          ^~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:117:26:
note: in instantiation of function template specialization
'llvm::PointerUnion<std::__debug::vector<unsigned char,
std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>::get<std::__debug::vector<unsigned int, std::allocator<unsigned

> *>' requested here

      delete OffsetCache.get<std::vector<uint32_t>*>();
                         ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:184:29:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *]
  template <typename T> int is() const {
                            ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:89:27:
error: no matching member function for call to 'get'
    Offsets = OffsetCache.get<std::vector<T> *>();
              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:136:17:
note: in instantiation of function template specialization
'llvm::SourceMgr::SrcBuffer::getLineNumber<unsigned char>' requested
here
    LineNo = SB.getLineNumber<uint8_t>(Ptr);
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:194:27:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned char, std::allocator<unsigned char> > *]
  template <typename T> T get() const {
                          ^
In file included from
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:15:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/Support/SourceMgr.h:20:
In file included from
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:18:
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:75:19:
error: no member named 'updateInt' in 'llvm::PointerIntPairInfo<void
*, 2, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

'

    Value = Info::updateInt(Info::updatePointer(0, PtrVal),
                  ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:53:5:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::setPointerAndInt' requested here

    setPointerAndInt(PtrVal, IntVal);
    ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:131:19:
note: in instantiation of member function 'llvm::PointerIntPair<void
*, 2, int, llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>::PointerIntPair' requested here

      this->Val = ValTy(
                  ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:79:17:
note: in instantiation of member function
'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPair<void *, 2, int,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> >
*>, llvm::PointerIntPairInfo<void *, 2,
llvm::pointer_union_detail::PointerUnionUIntTraits<std::__debug::vector<unsigned
char, std::allocator<unsigned char> > *, std::__debug::vector<unsigned
short, std::allocator<unsigned short> > *,
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *,
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *>

>, 0, std::__debug::vector<unsigned char, std::allocator<unsigned
> *, std::__debug::vector<unsigned short,

std::allocator<unsigned short> > *, std::__debug::vector<unsigned int,
std::allocator<unsigned int> > *, std::__debug::vector<unsigned long,
std::allocator<unsigned long> > *>::operator=' requested here
    OffsetCache = Offsets;
                ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:136:17:
note: in instantiation of function template specialization
'llvm::SourceMgr::SrcBuffer::getLineNumber<unsigned char>' requested
here
    LineNo = SB.getLineNumber<uint8_t>(Ptr);
                ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:89:27:
error: no matching member function for call to 'get'
    Offsets = OffsetCache.get<std::vector<T> *>();
              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:138:17:
note: in instantiation of function template specialization
'llvm::SourceMgr::SrcBuffer::getLineNumber<unsigned short>' requested
here
    LineNo = SB.getLineNumber<uint16_t>(Ptr);
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:194:27:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned short, std::allocator<unsigned short> >
*]
  template <typename T> T get() const {
                          ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:89:27:
error: no matching member function for call to 'get'
    Offsets = OffsetCache.get<std::vector<T> *>();
              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:140:17:
note: in instantiation of function template specialization
'llvm::SourceMgr::SrcBuffer::getLineNumber<unsigned int>' requested
here
    LineNo = SB.getLineNumber<uint32_t>(Ptr);
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:194:27:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned int, std::allocator<unsigned int> > *]
  template <typename T> T get() const {
                          ^
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:89:27:
error: no matching member function for call to 'get'
    Offsets = OffsetCache.get<std::vector<T> *>();
              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/home/jayfoad2/git/llvm-project/llvm/lib/Support/SourceMgr.cpp:142:17:
note: in instantiation of function template specialization
'llvm::SourceMgr::SrcBuffer::getLineNumber<unsigned long>' requested
here
    LineNo = SB.getLineNumber<uint64_t>(Ptr);
                ^
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:194:27:
note: candidate template ignored: substitution failure [with T =
std::__debug::vector<unsigned long, std::allocator<unsigned long> > *]
  template <typename T> T get() const {
                          ^
12 errors generated.

Any idea what's wrong, or what I'm doing wrong?

Thanks,
Jay.

Looks to me like a bug in GCC’s constexpr+_GLIBCXX_CONCEPT_CHECKS support. Small test case:

$ g+±8 test.cpp -std=c++2a -fsyntax-only
$ g+±8 test.cpp -std=c++2a -fsyntax-only -D_GLIBCXX_CONCEPT_CHECKS
In file included from /usr/include/c++/8/algorithm:62,
from test.cpp:1:
test.cpp:3:27: in ‘constexpr’ expansion of ‘std::min(std::initializer_list{((const int*)(& ._61)), 6})’
/usr/include/c++/8/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()); }

/usr/include/c++/8/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 /usr/include/c++/8/bits/move.h:34,
from /usr/include/c++/8/bits/stl_pair.h:59,
from /usr/include/c++/8/utility:70,
from /usr/include/c++/8/algorithm:60,
from test.cpp:1:
/usr/include/c++/8/bits/stl_algo.h:5613:7: error: call to non-‘constexpr’ function ‘void __gnu_cxx::__function_requires() [with _Concept = __gnu_cxx::_ForwardIteratorConcept<const int*>]’
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
^~~~~~~~~~~~~~~~~~~~~~~~~~~

Hmm. What about the errors I quoted from using clang-7 (starting about
a third of the way down my email, sorry if they got kinda lost in all
the noise)?

Thanks,
Jay.

It’s a bug in libstdc++ - so if you have clang using libstdc++ (which it will by default, I think) then it’s the same thing. You could try with libc++.

I just ran into this today. Do we need to update our requirements on
libstdc++ version?

Jay, did you figure out a way around this?

I locally commented out this line:

diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index fa92b7452a5…5fc5654aec2 100644
— a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -85,7 +85,7 @@ endif()

if(LLVM_ENABLE_EXPENSIVE_CHECKS)
add_definitions(-DEXPENSIVE_CHECKS)

  • add_definitions(-D_GLIBCXX_DEBUG)
  • #add_definitions(-D_GLIBCXX_DEBUG)
    endif()

string(TOUPPER “${LLVM_ABI_BREAKING_CHECKS}” uppercase_LLVM_ABI_BREAKING_CHECKS)

Jay.

Nice, thanks!