When a virtual destructor is encountered before any module providing std::align_val_t is loaded, DeclareGlobalNewDelete() implicitly creates a std::align_val_t EnumDecl. However, this EnumDecl was not added to the std namespace's DeclContext -- it was only stored in the Sema::StdAlignValT field. Later, when a module containing an explicit std::align_val_t definition is loaded, ASTReaderDecl::findExisting() attempts to find the implicit decl via DeclContext::noload_lookup() on the std namespace. Since the implicit EnumDecl was never added to that DeclContext, the lookup fails, and the two align_val_t declarations are not merged into a single redeclaration chain. This results in two distinct types both named std::align_val_t. The implicitly declared operator delete overloads (also created by DeclareGlobalNewDelete) use the implicit align_val_t type for their aligned-deallocation parameter. When module code (e.g. std::allocator:: deallocate) calls __builtin_operator_delete with the module's align_val_t, overload resolution fails because the two align_val_t types are not the same, producing: error: no matching function for call to 'operator delete' note: no known conversion from 'std::align_val_t' to 'std::align_val_t' The fix adds the implicit align_val_t EnumDecl to the std namespace DeclContext via getOrCreateStdNamespace()->addDecl(AlignValT), so the module merger can find it via noload_lookup and merge the two declarations. This bug was exposed by a libc++ change (2b01e7cf2b70) that removed the #include <__new/global_new_delete.h> line from allocate.h, which meant modules no longer had explicit operator delete declarations to paper over the type mismatch. Assisted-by: Claude Code
The LLVM Compiler Infrastructure
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Getting the Source Code and Building LLVM
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Getting in touch
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.