public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization
Date: Tue, 26 Dec 2023 01:36:13 +0000	[thread overview]
Message-ID: <bug-113141-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113141
           Summary: ICE on conversion to reference in aggregate
                    initialization
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Keywords: ice-checking, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

The following program triggers ICE since GCC 13
(https://godbolt.org/z/PaqWsG9s6):

```
int global_x{};

struct ConvToRef {
    operator int&() { return global_x; }
};

struct Foo { int& r; };

int main()
{
    Foo bar{ { ConvToRef{} } };
}
```

Clang considers this ill-formed and emits "non-const lvalue reference to type
'int' cannot bind to an initializer list temporary".

If the type of r is changed to const int&, the program correctly compiles with
GCC.

             reply	other threads:[~2023-12-26  1:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26  1:36 de34 at live dot cn [this message]
2023-12-26  5:12 ` [Bug c++/113141] " pinskia at gcc dot gnu.org
2023-12-26  5:14 ` [Bug c++/113141] [13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-02 18:25 ` ppalka at gcc dot gnu.org
2024-01-24  7:48 ` slyfox at gcc dot gnu.org
2024-01-24 15:47 ` ppalka at gcc dot gnu.org
2024-03-07 20:53 ` law at gcc dot gnu.org
2024-03-12 13:21 ` jakub at gcc dot gnu.org
2024-03-14 18:27 ` pinskia at gcc dot gnu.org
2024-03-21  9:07 ` pinskia at gcc dot gnu.org
2024-04-12 20:14 ` ppalka at gcc dot gnu.org
2024-04-12 20:15 ` ppalka at gcc dot gnu.org
2024-05-01 22:16 ` [Bug c++/113141] [13 " cvs-commit at gcc dot gnu.org
2024-05-01 22:19 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113141-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).