[clang] Reland "[Modules] Record whether VarDecl initializers contain side effects" (PR #145447)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 7 08:20:32 PDT 2025
ilya-biryukov wrote:
Here's a small repro:
```cpp
export module Foo;
export template <class Float>
struct Wrapper {
double value;
};
export constexpr Wrapper<double> Compute() {
return Wrapper<double>{1.0};
}
export template <typename Float>
Wrapper<Float> ComputeInFloat() {
const Wrapper<Float> a = Compute();
return a;
}
```
it fails when assertions are on: https://gcc.godbolt.org/z/vsW69z9Pd
The problem is that type of the `VarDecl` itself is dependent (the dependent `TemplateSpecializationType`) and so `castAs` fails.
My gut feeling is that the right fix would be to avoid running `CheckEvaluationResult` if `VarDecl` has a dependent type altogether and leave this diagnostic to template instantiations.
https://github.com/llvm/llvm-project/pull/145447
More information about the cfe-commits
mailing list