[clang] [clang] Fix LifetimeSafety build on 32-bit systems (PR #193440)

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 22 01:19:50 PDT 2026


mstorsjo wrote:

This isn't enough for fixing building on 32 bit platforms; I'm still seeing the following errors:
```
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:241:21: error: static assertion failed due to requirement 'Table.has_value()': Too many types for the available low bits
  241 |       static_assert(Table.has_value(),
      |                     ^~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:260:32: note: in instantiation of member function 'llvm::PointerUnion<const clang::MaterializeTemporaryExpr *, const clang::CXXNewExpr *, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>::getTagTable' requested here
  260 |     constexpr TagTable Table = getTagTable();
      |                                ^
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:154:54: note: in instantiation of function template specialization 'llvm::PointerUnion<const clang::MaterializeTemporaryExpr *, const clang::CXXNewExpr *, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>::encode<const clang::ValueDecl *>' requested here
  154 |   PointerUnionMembers(Type V) { this->Val = Derived::encode(V); }
      |                                                      ^
llvm-project/llvm/tools/clang/include/clang/Analysis/Analyses/LifetimeSafety/Loans.h:63:63: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<const clang::MaterializeTemporaryExpr *, const clang::CXXNewExpr *, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>, 2, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>::PointerUnionMembers' requested here
   63 |   AccessPath(const clang::ValueDecl *D) : K(Kind::ValueDecl), Root(D) {}
      |                                                               ^
In file included from <built-in>:1:
In file included from llvm-project/llvm/build-mingw-i686/tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/cmake_pch.hxx:5:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/pch.h:13:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/ASTContext.h:18:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/CanonicalType.h:17:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/Type.h:20:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/Decl.h:17:
In file included from llvm-project/llvm/tools/clang/include/clang/AST/APValue.h:22:
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:260:24: error: constexpr variable 'Table' must be initialized by a constant expression
  260 |     constexpr TagTable Table = getTagTable();
      |                        ^       ~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:154:54: note: in instantiation of function template specialization 'llvm::PointerUnion<const clang::MaterializeTemporaryExpr *, const clang::CXXNewExpr *, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>::encode<const clang::ValueDecl *>' requested here
  154 |   PointerUnionMembers(Type V) { this->Val = Derived::encode(V); }
      |                                                      ^
llvm-project/llvm/tools/clang/include/clang/Analysis/Analyses/LifetimeSafety/Loans.h:63:63: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<const clang::MaterializeTemporaryExpr *, const clang::CXXNewExpr *, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>, 2, const clang::ValueDecl *, const clang::ParmVarDecl *, const clang::CXXMethodDecl *>::PointerUnionMembers' requested here
   63 |   AccessPath(const clang::ValueDecl *D) : K(Kind::ValueDecl), Root(D) {}
      |                                                               ^
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:243:14: note: read of member '__val_' of union with active member '__null_state_' is not allowed in a constant expression
  243 |       return *Table;
      |              ^
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:243:14: note: in call to 'array(Table.__optional_destruct_base::union (anonymous union at /home/martin/clang-20.1.8/i686-w64-mingw32/include/c++/v1/optional:328:3).__optional_destruct_base::__val_)'
  243 |       return *Table;
      |              ^~~~~~
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:260:32: note: in call to 'getTagTable()'
  260 |     constexpr TagTable Table = getTagTable();
      |                                ^~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:263:19: error: static assertion expression is not an integral constant expression
  263 |     static_assert(Table[0].Value == 0,
      |                   ^~~~~~~~~~~~~~~~~~~
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:263:19: note: initializer of 'Table' is not a constant expression
llvm-project/llvm/include/llvm/ADT/PointerUnion.h:260:24: note: declared here
  260 |     constexpr TagTable Table = getTagTable();
      |                        ^
```

https://github.com/llvm/llvm-project/pull/193440


More information about the cfe-commits mailing list