public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue
@ 2021-11-11  8:49 de34 at live dot cn
  2023-11-28 17:11 ` [Bug c++/103185] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: de34 at live dot cn @ 2021-11-11  8:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103185
           Summary: ind[arr] is rejected when arr is an array prvalue
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Keywords: 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.

#include <type_traits>

int main()
{
    using intarr = int[];
    static_assert(std::is_same<decltype(0[intarr{0}]), int&&>::value, "");
}

It seems that arr[ind]("intarr{0}[0]") doesn't suffer from this bug.

Gcc 9 correctly accepted this code.

wandbox links:
gcc 12.0 (-std=c++17): https://wandbox.org/permlink/AQGr8pUXHQkPrJ9m
gcc 12.0 (-std=c++14): https://wandbox.org/permlink/aYpBwLVK8tsDHTl3
gcc 10.1 (-std=c++17): https://wandbox.org/permlink/nnWuZAawBZnrmHvN
gcc 10.1 (-std=c++14): https://wandbox.org/permlink/4fNJLiqU5VaMZPfm
gcc  9.3 (-std=c++17): https://wandbox.org/permlink/vugrP8zIzBSPiVup

Perhaps this bug is related to bug 94264 and bug 103183.

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

* [Bug c++/103185] [11/12/13/14 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
@ 2023-11-28 17:11 ` ppalka at gcc dot gnu.org
  2023-11-28 17:11 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-28 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ind[arr] is rejected when   |[11/12/13/14 Regression]
                   |arr is an array prvalue     |ind[arr] is rejected when
                   |                            |arr is an array prvalue
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started to be rejected in C++17 mode since r10-3793-g1a37b6d9a7e57c:

using intarr = int[];
using type = decltype(0[intarr{0}]); // { dg-bogus "taking address of temporary
array" }

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

* [Bug c++/103185] [11/12/13/14 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
  2023-11-28 17:11 ` [Bug c++/103185] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
@ 2023-11-28 17:11 ` ppalka at gcc dot gnu.org
  2023-12-19 20:58 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-28 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5

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

* [Bug c++/103185] [11/12/13/14 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
  2023-11-28 17:11 ` [Bug c++/103185] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
  2023-11-28 17:11 ` ppalka at gcc dot gnu.org
@ 2023-12-19 20:58 ` jason at gcc dot gnu.org
  2023-12-20 17:31 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2023-12-19 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
                 CC|                            |jason at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-12-19
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug c++/103185] [11/12/13/14 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
                   ` (2 preceding siblings ...)
  2023-12-19 20:58 ` jason at gcc dot gnu.org
@ 2023-12-20 17:31 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:39 ` [Bug c++/103185] [11/12/13 " cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-20 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e

commit r14-6753-g8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 19 16:12:02 2023 -0500

    c++: xvalue array subscript [PR103185]

    Normally we handle xvalue array subscripting with ARRAY_REF, but in this
    case we weren't doing that because the operands were reversed.  Handle that
    case better.

            PR c++/103185

    gcc/cp/ChangeLog:

            * typeck.cc (cp_build_array_ref): Handle swapped operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/array-prvalue2.C: New test.
            * g++.dg/cpp1z/eval-order3.C: Test swapped operands.

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

* [Bug c++/103185] [11/12/13 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
                   ` (3 preceding siblings ...)
  2023-12-20 17:31 ` cvs-commit at gcc dot gnu.org
@ 2024-01-24 19:39 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-24 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:fcc06cf83a9571a0745fcde83d955eb7d7f16910

commit r13-8248-gfcc06cf83a9571a0745fcde83d955eb7d7f16910
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 19 16:12:02 2023 -0500

    c++: xvalue array subscript [PR103185]

    Normally we handle xvalue array subscripting with ARRAY_REF, but in this
    case we weren't doing that because the operands were reversed.  Handle that
    case better.

            PR c++/103185

    gcc/cp/ChangeLog:

            * typeck.cc (cp_build_array_ref): Handle swapped operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/array-prvalue2.C: New test.
            * g++.dg/cpp1z/eval-order3.C: Test swapped operands.

    (cherry picked from commit 8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e)

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

* [Bug c++/103185] [11/12/13 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
                   ` (4 preceding siblings ...)
  2024-01-24 19:39 ` [Bug c++/103185] [11/12/13 " cvs-commit at gcc dot gnu.org
@ 2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:45 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:45 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-24 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:0da4402bd4b350691b2301003de62268f865d91c

commit r12-10111-g0da4402bd4b350691b2301003de62268f865d91c
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 19 16:12:02 2023 -0500

    c++: xvalue array subscript [PR103185]

    Normally we handle xvalue array subscripting with ARRAY_REF, but in this
    case we weren't doing that because the operands were reversed.  Handle that
    case better.

            PR c++/103185

    gcc/cp/ChangeLog:

            * typeck.cc (cp_build_array_ref): Handle swapped operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/array-prvalue2.C: New test.
            * g++.dg/cpp1z/eval-order3.C: Test swapped operands.

    (cherry picked from commit 8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e)

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

* [Bug c++/103185] [11/12/13 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
                   ` (5 preceding siblings ...)
  2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
@ 2024-01-24 19:45 ` cvs-commit at gcc dot gnu.org
  2024-01-24 19:45 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-24 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:89e4f3304ad45d2251bfaf66d2a355cebf87310b

commit r11-11208-g89e4f3304ad45d2251bfaf66d2a355cebf87310b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 19 16:12:02 2023 -0500

    c++: xvalue array subscript [PR103185]

    Normally we handle xvalue array subscripting with ARRAY_REF, but in this
    case we weren't doing that because the operands were reversed.  Handle that
    case better.

            PR c++/103185

    gcc/cp/ChangeLog:

            * typeck.c (cp_build_array_ref): Handle swapped operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/array-prvalue2.C: New test.
            * g++.dg/cpp1z/eval-order3.C: Test swapped operands.

    (cherry picked from commit 8dfc52a75d4d6c8be1c61b4aa831b1812b14a10e)

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

* [Bug c++/103185] [11/12/13 Regression] ind[arr] is rejected when arr is an array prvalue
  2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
                   ` (6 preceding siblings ...)
  2024-01-24 19:45 ` cvs-commit at gcc dot gnu.org
@ 2024-01-24 19:45 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2024-01-24 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.5/12.4/13.3.

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

end of thread, other threads:[~2024-01-24 19:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  8:49 [Bug c++/103185] New: ind[arr] is rejected when arr is an array prvalue de34 at live dot cn
2023-11-28 17:11 ` [Bug c++/103185] [11/12/13/14 Regression] " ppalka at gcc dot gnu.org
2023-11-28 17:11 ` ppalka at gcc dot gnu.org
2023-12-19 20:58 ` jason at gcc dot gnu.org
2023-12-20 17:31 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:39 ` [Bug c++/103185] [11/12/13 " cvs-commit at gcc dot gnu.org
2024-01-24 19:40 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:45 ` cvs-commit at gcc dot gnu.org
2024-01-24 19:45 ` jason 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).