This is the same issue as PR86429, just in potential_constant_expression_1 rather than cxx_eval_constant_expression. As in that case, when we're trying to evaluate a constant expression within a lambda, we don't have a constant closure object to refer to, but we can try to refer directly to the captured variable. gcc/cp/ChangeLog 2020-05-05 Jason Merrill <jason@redhat.com> PR c++/90212 * constexpr.c (potential_constant_expression_1): In a lambda function, consider a captured variable directly.
14 lines
255 B
C
14 lines
255 B
C
// PR c++/90212
|
|
// { dg-do compile { target c++11 } }
|
|
|
|
template<typename T> struct tuple {
|
|
constexpr tuple(T&& t) : t(t) { }
|
|
int t;
|
|
};
|
|
|
|
void foo() {
|
|
constexpr tuple<int> v1{1};
|
|
constexpr auto v2 = v1;
|
|
[&]{ constexpr auto v2 = v1; };
|
|
}
|