public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110565] New: Incomplete note on why initializing int& with int is ill-formed
@ 2023-07-05 19:36 blubban at gmail dot com
  2023-07-05 23:13 ` [Bug c++/110565] [10/11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: blubban at gmail dot com @ 2023-07-05 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110565
           Summary: Incomplete note on why initializing int& with int is
                    ill-formed
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

struct X {
    X(int&);
    X(X&&) = delete; // the issue reproduces without this line, but the error
is clearer with it
};

template<int>
void f() {
    new X(0);
}


Expected output:

<source>: In function 'void f()':
<source>:8:12: error: no matching function for call to 'X::X(int)'
    8 |     new X(0);
      |            ^
<source>:2:5: note: candidate: 'X::X(int&)' (near match)
    2 |     X(int&);
      |     ^
<source>:2:5: note:   conversion of argument 1 would be ill-formed:
<source>:8:11: error: cannot bind non-const lvalue reference of type 'int&' to
an rvalue of type 'int'


Actual output:

<source>: In function 'void f()':
<source>:8:12: error: no matching function for call to 'X::X(int)'
    8 |     new X(0);
      |            ^
<source>:2:5: note: candidate: 'X::X(int&)' (near match)
    2 |     X(int&);
      |     ^
<source>:2:5: note:   conversion of argument 1 would be ill-formed:


The template and new-expression are necessary; the error is proper without
them.

https://godbolt.org/z/c1Er5nsjd

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

end of thread, other threads:[~2024-03-11 14:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 19:36 [Bug c++/110565] New: Incomplete note on why initializing int& with int is ill-formed blubban at gmail dot com
2023-07-05 23:13 ` [Bug c++/110565] [10/11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-07-06  8:18 ` rguenth at gcc dot gnu.org
2023-07-07 10:45 ` [Bug c++/110565] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-03-07 23:30 ` law at gcc dot gnu.org
2024-03-11 14:27 ` redi 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).