llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

static_assert(llvm::is_sorted_constexpr(...)) fails with std::initializer_list

Open Rayfxl opened this issue 9 months ago • 4 comments

Describe the bug

When using static_assert(llvm::is_sorted_constexpr(SupportedOp)) where SupportedOp is a constexpr static std::initializer_list<unsigned>, compilation fails with: error: static_assert expression is not an integral constant expression

This happens when I run cmake --build . --target check-mlir, and my cmake command is cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON -DLLVM_CCACHE_BUILD=ON -DMLIR_INCLUDE_INTEGRATION_TESTS=ON -DLLVM_USE_SPLIT_DWARF=ON

Replacing std::initializer_list with std::array works as expected.

Is this an existing issue? Or anyone also encountered this problem?

Image

Rayfxl avatar Mar 02 '26 15:03 Rayfxl

Can you come up with a standalone reproducer?

tbaederr avatar Mar 02 '26 16:03 tbaederr

@bababuck

alexey-bataev avatar Mar 03 '26 16:03 alexey-bataev

@Rayfxl which version of clang are you using? (/usr/bin/clang++ --version)

bababuck avatar Mar 03 '26 18:03 bababuck

I suspect that the error is related to an older clang version being used to compile, but cannot confirm without knowing what version was used.

bababuck avatar Mar 05 '26 23:03 bababuck