Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,8 @@ bool VarDecl::hasInitWithSideEffects() const {
ES->HasSideEffects =
E->HasSideEffects(getASTContext()) &&
// We can get a value-dependent initializer during error recovery.
(E->isValueDependent() || !evaluateValue());
(E->isValueDependent() || getType()->isDependentType() ||
!evaluateValue());
ES->CheckedForSideEffects = true;
}
return ES->HasSideEffects;
Expand Down
20 changes: 20 additions & 0 deletions clang/test/Modules/var-init-side-effects-templated.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Tests referencing variable with initializer containing side effect across module boundary

// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t

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;
}
Loading