public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue @ 2021-11-11 8:38 de34 at live dot cn 2021-11-11 9:56 ` [Bug c++/103183] " pinskia at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: de34 at live dot cn @ 2021-11-11 8:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 Bug ID: 103183 Summary: ind[arr] produces an lvalue when arr is an array xvalue Product: gcc Version: 10.1.0 Status: UNCONFIRMED Keywords: accepts-invalid, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- With gcc 10 and later versions, the following program compiles in C++11/14 modes, but fails to compile in C++17 and later modes. It compiles in C++17 and later modes if "int&&" is replaced with "int&" (which is wrong according to [expr.sub]/2). #include <type_traits> #include <utility> int main() { int arr[]{0}; static_assert(std::is_same<decltype(0[std::move(arr)]), int&&>::value, ""); } It seems that arr[ind] doesn't suffer from this bug. Gcc 9 correctly produced an xvalue in this case. wandbox links (rejected valid code): gcc 12.0 (-std=c++17): https://wandbox.org/permlink/HvNaq9T4J7oeYflt gcc 12.0 (-std=c++14): https://wandbox.org/permlink/S3dhGvKr3aD5OeOW gcc 10.1 (-std=c++17): https://wandbox.org/permlink/NzqYCtytSUW4oZjR gcc 10.1 (-std=c++14): https://wandbox.org/permlink/LviIophRujplHx6o gcc 9.3 (-std=c++17): https://wandbox.org/permlink/JkCQHBdc3xqDSG9s wandbox links (accepted invalid code, with "int&&" replaced with "int&"): gcc 12.0 (-std=c++17): https://wandbox.org/permlink/JkCQHBdc3xqDSG9s gcc 10.1 (-std=c++17): https://wandbox.org/permlink/Yr3Vl2mbeDzGi02v ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn @ 2021-11-11 9:56 ` pinskia at gcc dot gnu.org 2021-11-11 9:59 ` pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-11-11 9:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There has to be C++ defect report about this. Because clang has the behavior you are requesting but ICC, MSVC all act the same as GCC. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn 2021-11-11 9:56 ` [Bug c++/103183] " pinskia at gcc dot gnu.org @ 2021-11-11 9:59 ` pinskia at gcc dot gnu.org 2021-11-11 10:00 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-11-11 9:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Found it PR 79832. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn 2021-11-11 9:56 ` [Bug c++/103183] " pinskia at gcc dot gnu.org 2021-11-11 9:59 ` pinskia at gcc dot gnu.org @ 2021-11-11 10:00 ` pinskia at gcc dot gnu.org 2023-11-28 17:19 ` [Bug c++/103183] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-11-11 10:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #2) > Found it PR 79832. Well DR 1213, http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1213 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] [11/12/13/14 Regression] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn ` (2 preceding siblings ...) 2021-11-11 10:00 ` pinskia at gcc dot gnu.org @ 2023-11-28 17:19 ` ppalka at gcc dot gnu.org 2023-12-21 8:52 ` de34 at live dot cn 2024-03-10 3:21 ` law at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: ppalka at gcc dot gnu.org @ 2023-11-28 17:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org Summary|ind[arr] produces an lvalue |[11/12/13/14 Regression] |when arr is an array xvalue |ind[arr] produces an lvalue | |when arr is an array xvalue Target Milestone|--- |11.5 --- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- Like PR103185, this one also started with r10-3793-g1a37b6d9a7e57c ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] [11/12/13/14 Regression] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn ` (3 preceding siblings ...) 2023-11-28 17:19 ` [Bug c++/103183] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org @ 2023-12-21 8:52 ` de34 at live dot cn 2024-03-10 3:21 ` law at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: de34 at live dot cn @ 2023-12-21 8:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 --- Comment #5 from Jiang An <de34 at live dot cn> --- Seems fixed together by commit r14-6753-g8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e. https://godbolt.org/z/on3K451a5 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/103183] [11/12/13/14 Regression] ind[arr] produces an lvalue when arr is an array xvalue 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn ` (4 preceding siblings ...) 2023-12-21 8:52 ` de34 at live dot cn @ 2024-03-10 3:21 ` law at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: law at gcc dot gnu.org @ 2024-03-10 3:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103183 Jeffrey A. Law <law at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |law at gcc dot gnu.org Resolution|--- |FIXED --- Comment #6 from Jeffrey A. Law <law at gcc dot gnu.org> --- Per c#5. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-10 3:21 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-11-11 8:38 [Bug c++/103183] New: ind[arr] produces an lvalue when arr is an array xvalue de34 at live dot cn 2021-11-11 9:56 ` [Bug c++/103183] " pinskia at gcc dot gnu.org 2021-11-11 9:59 ` pinskia at gcc dot gnu.org 2021-11-11 10:00 ` pinskia at gcc dot gnu.org 2023-11-28 17:19 ` [Bug c++/103183] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org 2023-12-21 8:52 ` de34 at live dot cn 2024-03-10 3:21 ` law at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).