https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63764
--- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- On Tue, 18 Nov 2014, jakub at gcc dot gnu.org wrote: > > Maybe build_array_ref needs to ensure that references to elements of > > non-lvalue vectors don't become lvalues? (This would be different to > > non-lvalue arrays arising from non-lvalue structs and unions, where the > > result of an array reference *is* an lvalue but modifying it, or accessing > > it after the next sequence point, has undefined behavior.) > > Apparently I misremembered it, trying it again, I see the VCE still there in > *vecp upon entry to convert_vector_to_pointer_for_subscript, the difference > between VIEW_CONVERT_EXPR and NON_LVALUE_EXPR is just that > c_common_mark_addressable_vec looks through VCE and marks the inner part as > addressable (because VCE is handled_component_p), while for non_lvalue_expr it > does not. > > So, shall we convert_vector_to_pointer_for_subscript add something like > if (!lvalue_p (*vecp)) > error_at (...); ? > What wording for it? I'd think it's reasonable to subscript a non-lvalue vector (including e.g. the return value of a function with vector return type) - this might of course need to create a temporary object, as with non-lvalue arrays.