Is this a regression? -r288654 Attn rsmith

Ok, I hate to self-respond, but I think I've convinced myself (With Clark's help), that despite GCC and older Clang supporting this case, that it shouldn't be legal by reading of the standard.

Essentially, this is the exact same thing as:
foo().a[2] = 5;
Which, I would expect to fail, since assigning to a temporary is insane and illegal for a good reason. The GLValue solution I proposed below is incorrect because:

5.18(Assignment and compound assignment operators):
The assignment operator... require a modifiable lvalue as their left operand and return an lvalue referring to the left operand.

Then, the DR that Richard was fixing changed 5.2.1 to say:
5.2.1(Subscripting):
The expression E1[E2] is identical (by definition) to *((E1)+(E2)), except that in the case of an array operand, the result is an lvalue if that operand is an lvalue, and an xvalue otherwise.

AKA, subscripting an xvalue array is still an xvalue, and thus cannot be assigned to.

Finally, a constcast to a rvalue reference of an Object Type is an xvalue:
5.2.11(Const cast):
The result of the expression const_cast<T>(v) is of type T. If T is an lvalue reference to an object type, the result is an lvalue; if T is an rvalue reference to an object type, the result is an xvalue;...

Meaning that the const cast below is an xvalue, thus subscripting it is an xvalue, thus assigning to it is insane.

I believe the correct response here is for me to fix our tests :slight_smile: