[clang] [clang] check constant template parameters in dependent contexts (PR #159463)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 19 06:20:15 PDT 2025


erichkeane wrote:

> Note @mizvekov : we observed on an internal test (I am going to have someone work on minimizing it) that this causes an assertion. As you can see, it is all in boost, so a reduction might take a while, but was hoping you might see something obvious in advance:
> 
> ```
> clang++: /proj/build/llvm/Linux_x86_64/clang/lib/AST/ExprClassification.cpp:57: Cl clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const: Assertion `isLValue()' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
> Stack dump:
> 0.	Program arguments: /proj/nv/llvm/Linux_x86_64/llvm-6094/bin/clang++ -c -o library/SolverUtils/Core/CouplingFile.o -DSPEC -DNDEBUG -DSPEC_AUTO_SUPPRESS_THREADING -Ithirdparty/zlib-1.3 -DTIXML_USE_STL -DBOOST_ENDIAN_NO_INTRINSICS -DBOOST_DISABLE_THREADS -Ithirdparty/tinyxml-2.6.2 -Ithirdparty/boost-1.84.0/include -Ilibrary/ -Isolvers/ --std=c++17 -fno-fast-math -DSPEC_LP64 library/SolverUtils/Core/CouplingFile.cpp
> 1.	thirdparty/boost-1.84.0/include/boost/mp11/algorithm.hpp:226:18: at annotation token
> 2.	thirdparty/boost-1.84.0/include/boost/mp11/algorithm.hpp:29:1: parsing namespace 'boost'
> 3.	thirdparty/boost-1.84.0/include/boost/mp11/algorithm.hpp:31:1: parsing namespace 'boost::mp11'
> 4.	thirdparty/boost-1.84.0/include/boost/mp11/algorithm.hpp:199:1: parsing namespace 'boost::mp11::detail'
> 5.	thirdparty/boost-1.84.0/include/boost/mp11/algorithm.hpp:224:57: parsing struct/union/class body 'boost::mp11::detail::mp_fill_impl<L<A...>, V>'
>  #0 0x0000000004622358 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/proj/nv/llvm/Linux_x86_64/llvm-6094/bin/clang+++0x4622358)
>  #1 0x000000000461f77c llvm::sys::CleanupOnSignal(unsigned long) (/proj/nv/llvm/Linux_x86_64/llvm-6094/bin/clang+++0x461f77c)
>  #2 0x000000000456c088 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
>  #3 0x000014e6172cf520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
>  #4 0x000014e6173239fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
>  #5 0x000014e6173239fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
>  #6 0x000014e6173239fc pthread_kill ./nptl/pthread_kill.c:89:10
>  #7 0x000014e6172cf476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
>  #8 0x000014e6172b57f3 abort ./stdlib/abort.c:81:7
>  #9 0x000014e6172b571b _nl_load_domain ./intl/loadmsgcat.c:1177:9
> #10 0x000014e6172c6e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
> #11 0x000000000811f5c6 clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const (/proj/nv/llvm/Linux_x86_64/llvm-6094/bin/clang+++0x811f5c6)
> #12 0x0000000007a27d90 clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*, clang::QualType&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::TemplateSpecCandidateSet*) (/proj/nv/llvm/Linux_x86_64/llvm-6094/bin/clang+++0x7a27d90)```
> ```

I actually repro'd off the stack trace :)
https://godbolt.org/z/WGz58WdEd

```
template<class L, class V> struct mp_fill_impl
{};

template<template<auto...> class L, auto... A, class V> struct mp_fill_impl<L<A...>, V>
{
    using type = L<((void)A, V::value)...>;
};
```



AS this is a part of Boost/major libraries and is a pretty simple bit of valid code, if you can't get a fix reasonably fast, please consider a revert.



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


More information about the cfe-commits mailing list