[cfe-dev] Is this a regression? -r288654 Attn rsmith

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 24 15:20:00 PDT 2017


TL;DR: Should the example below work as it did before R288654?  If so, can someone hint as to where I can fix this?


Hi All-
Our automated system detected that some old r-value reference tests started failing.  Most simply:

long long x[37] = {37, 47, 59};
int main() {
	const_cast<decltype(x)&&>(x)[2] += 387;
	}

Fails with:  error: expression is not assignable
On the += operator.

Previously, this succeeded.  Interestingly, running this in -std=c++03 mode works (though warns that && is a C++11 feature).

The change in behavior is a result of  the ExprClassification.cpp changes in R288654 (the C+=11 addition to ClassifyInternal in Expr::ArraySubscriptExprClass).

It previously identified as a Cl::CL_LValue, however switched to being a CL_XValue, which SEEMS like the correct classification, as a cast to an rvalue reference of an Object is an XValue.  That said, I would still expect that assignment to be permitted, right?  Is the problem that ExprClassification.cpp's isModifiableLvalue classifies a CL_XValue as an MLV_InvalidExpression?

Or is CheckASignmentOperands checking the wrong thing? That it is a ModifiableLvalue rather than a modifiable GLValue?

Thanks,
Erich



More information about the cfe-dev mailing list