public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111286] New: ICE on functional cast to const array reference
@ 2023-09-04 19:12 leni536 at gmail dot com
  2023-09-04 19:18 ` [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: leni536 at gmail dot com @ 2023-09-04 19:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111286
           Summary: ICE on functional cast to const array reference
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leni536 at gmail dot com
  Target Milestone: ---

With g++ 13.2.0
with flags: -std=c++20

The following code:

```
struct A {
    A() noexcept {}
};

void foo() {
    using T = const A (&)[1];
    T{};
}
```

Produces the following compiler output:

<source>: In function 'void foo()':
<source>:7:7: internal compiler error: in cp_build_addr_expr_1, at
cp/typeck.cc:7147
    7 |     T{};
      |       ^
0x1ce7bde internal_error(char const*, ...)
        ???:0
0x7290fc fancy_abort(char const*, int, char const*)
        ???:0
0x74b040 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        ???:0
0x8e9510 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
        ???:0
0x89fd5b c_parse_file()
        ???:0
0x98c5d9 c_common_parse_file()
        ???:0


https://godbolt.org/z/MaWTTv4Y7

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
@ 2023-09-04 19:18 ` pinskia at gcc dot gnu.org
  2023-09-05 14:19 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-04 19:18 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.4
      Known to fail|                            |12.1.0
           Keywords|                            |ice-on-valid-code,
                   |                            |needs-bisection
            Summary|ICE on functional cast      |[12/13/14 Regression] ICE
                   |empty brace-init-list to    |on functional cast empty
                   |const array reference       |brace-init-list to const
                   |                            |array reference
      Known to work|                            |11.4.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-09-04

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
  2023-09-04 19:18 ` [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list " pinskia at gcc dot gnu.org
@ 2023-09-05 14:19 ` mpolacek at gcc dot gnu.org
  2023-09-13  7:01 ` gayathri.gottumukkala.27 at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-09-05 14:19 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Keywords|needs-bisection             |
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r12-7069:

commit 119cea98f664764cce04963243c39c8f6d797d33
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 2 18:36:41 2022 -0500

    c++: assignment, aggregate, array [PR104300]

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
  2023-09-04 19:18 ` [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list " pinskia at gcc dot gnu.org
  2023-09-05 14:19 ` mpolacek at gcc dot gnu.org
@ 2023-09-13  7:01 ` gayathri.gottumukkala.27 at gmail dot com
  2024-02-05 18:40 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: gayathri.gottumukkala.27 at gmail dot com @ 2023-09-13  7:01 UTC (permalink / raw)
  To: gcc-bugs

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

Gayathri Gottumukkala <gayathri.gottumukkala.27 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gayathri.gottumukkala.27@gm
                   |                            |ail.com

--- Comment #3 from Gayathri Gottumukkala <gayathri.gottumukkala.27 at gmail dot com> ---
I think this issue is related to the attempt to create a temporary array of
references, which is not allowed in C++.

In C++11 and later, you can find this information in section 8.3.2, paragraph 4
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf

According to the above document, "There shall be no references to references,
no arrays of references, and no pointers to references."

To address the compilation error without modifying the code structure, we can
make use of a temporary array of const A objects.

struct A {
    A() noexcept {}
};

void foo() {
    using T = const A[1];
    T{};
}

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
                   ` (2 preceding siblings ...)
  2023-09-13  7:01 ` gayathri.gottumukkala.27 at gmail dot com
@ 2024-02-05 18:40 ` jason at gcc dot gnu.org
  2024-02-05 21:33 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2024-02-05 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
                   ` (3 preceding siblings ...)
  2024-02-05 18:40 ` jason at gcc dot gnu.org
@ 2024-02-05 21:33 ` cvs-commit at gcc dot gnu.org
  2024-02-05 22:25 ` 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-02-05 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:c7e8381748f78335e9fef23f363b6a9e4463ce7e

commit r14-8811-gc7e8381748f78335e9fef23f363b6a9e4463ce7e
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 13:54:22 2024 -0500

    c++: prvalue of array type [PR111286]

    Here we want to build a prvalue array to bind to the T reference, but we
    were wrongly trying to strip cv-quals from the array prvalue, which should
    be treated the same as a class prvalue.

            PR c++/111286

    gcc/cp/ChangeLog:

            * tree.cc (rvalue): Don't drop cv-quals from an array.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist-array22.C: New test.

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
                   ` (4 preceding siblings ...)
  2024-02-05 21:33 ` cvs-commit at gcc dot gnu.org
@ 2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
  2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
  2024-02-05 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-05 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:3add6b9ceefe37faac82e2d24b11c6f45e630877

commit r12-10135-g3add6b9ceefe37faac82e2d24b11c6f45e630877
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 13:54:22 2024 -0500

    c++: prvalue of array type [PR111286]

    Here we want to build a prvalue array to bind to the T reference, but we
    were wrongly trying to strip cv-quals from the array prvalue, which should
    be treated the same as a class prvalue.

            PR c++/111286

    gcc/cp/ChangeLog:

            * tree.cc (rvalue): Don't drop cv-quals from an array.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist-array22.C: New test.

    (cherry picked from commit c7e8381748f78335e9fef23f363b6a9e4463ce7e)

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
                   ` (5 preceding siblings ...)
  2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
@ 2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
  2024-02-05 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-05 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:c21c46032ebafb8fc36b7f02f2886a831e8c696a

commit r13-8283-gc21c46032ebafb8fc36b7f02f2886a831e8c696a
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 5 13:54:22 2024 -0500

    c++: prvalue of array type [PR111286]

    Here we want to build a prvalue array to bind to the T reference, but we
    were wrongly trying to strip cv-quals from the array prvalue, which should
    be treated the same as a class prvalue.

            PR c++/111286

    gcc/cp/ChangeLog:

            * tree.cc (rvalue): Don't drop cv-quals from an array.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/initlist-array22.C: New test.

    (cherry picked from commit c7e8381748f78335e9fef23f363b6a9e4463ce7e)

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

* [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list to const array reference
  2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
                   ` (6 preceding siblings ...)
  2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
@ 2024-02-05 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2024-02-05 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2024-02-05 22:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04 19:12 [Bug c++/111286] New: ICE on functional cast to const array reference leni536 at gmail dot com
2023-09-04 19:18 ` [Bug c++/111286] [12/13/14 Regression] ICE on functional cast empty brace-init-list " pinskia at gcc dot gnu.org
2023-09-05 14:19 ` mpolacek at gcc dot gnu.org
2023-09-13  7:01 ` gayathri.gottumukkala.27 at gmail dot com
2024-02-05 18:40 ` jason at gcc dot gnu.org
2024-02-05 21:33 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:25 ` cvs-commit at gcc dot gnu.org
2024-02-05 22:26 ` 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).