LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25357 - Subscript operator applied to an temporary array results in an lvalue
Summary: Subscript operator applied to an temporary array results in an lvalue
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++14 (show other bugs)
Version: 3.7
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-30 13:18 PDT by Shafik Yaghmour
Modified: 2017-10-14 11:09 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shafik Yaghmour 2015-10-30 13:18:48 PDT
This Stackoverflow question http://stackoverflow.com/questions/33161003/using-a-temporary-array-as-an-lvalue provides the following code:

using Y = int[10];

int main() {
    (Y { })[0] = 1;
}

which compiles without diagnostic, if I am reading CWG defect report 1213 correctly http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1213 then the result of the  subscript operator should be an xvalue and therefore not assignable to. Is this a correct interpretation?

The clang defect report status page does list the status of DR 1213 as unknown http://clang.llvm.org/cxx_dr_status.html but since this has come up on a couple of SO questions already I thought it was worth it to file a bug report.

I have a Wandbox example here http://melpon.org/wandbox/permlink/tiLfQnvsvBsAtNZv
Comment 1 Nicolas Lesser 2017-10-14 11:09:19 PDT
Thanks! This has been resolved in clang 4.0.0: https://godbolt.org/g/ec8ymp