public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106775] New: [11/12 regression] Subscipt operator with array rvalue inside brackets returns lvalue
@ 2022-08-30  2:49 leduyquang753 at gmail dot com
  2022-08-30  7:11 ` [Bug c++/106775] [11/12/13 " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: leduyquang753 at gmail dot com @ 2022-08-30  2:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106775

            Bug ID: 106775
           Summary: [11/12 regression] Subscipt operator with array rvalue
                    inside brackets returns lvalue
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leduyquang753 at gmail dot com
  Target Milestone: ---

Created attachment 53519
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53519&action=edit
The command-line invocation of GCC, its verbose output and the preprocessed
source.

Using the built-in subscript operator with an array rvalue to the left (outside
brackets) and an integer to the right (inside brackets) returns an xvalue as
expected:

    test.cpp:10:21: error: using rvalue as lvalue [-fpremissive]
       10 |     getAnA().b[0] = 1;
          |     ~~~~~~~~~~~~^

But reversing the two operands makes GCC give an lvalue:

    0[getAnA().b] = 1;

No diagnostic with -Wall -Wextra -pedantic.

(Full preprocessed code attached.)

Test compiled using GCC 12.2.0 on Arch Linux and additionally on Windows and
Compiler explorer. Previous versions of GCC were tested on Compiler explorer
using x86-64 arch.

Other notes: MSVC in Visual studio 2022 seems to have the same issue while
Clang 14 doesn't.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-29 10:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30  2:49 [Bug c++/106775] New: [11/12 regression] Subscipt operator with array rvalue inside brackets returns lvalue leduyquang753 at gmail dot com
2022-08-30  7:11 ` [Bug c++/106775] [11/12/13 " rguenth at gcc dot gnu.org
2022-08-30 12:59 ` [Bug c++/106775] [10/11/12/13 " mpolacek at gcc dot gnu.org
2022-08-30 13:10 ` mpolacek at gcc dot gnu.org
2022-08-30 17:02 ` jakub at gcc dot gnu.org
2022-10-19  7:05 ` rguenth at gcc dot gnu.org
2023-05-29 10:07 ` [Bug c++/106775] [10/11/12/13/14 " jakub 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).