public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100039] New: GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression
@ 2021-04-11 23:45 vanyacpp at gmail dot com
  2021-04-12  0:06 ` [Bug c++/100039] " mpolacek at gcc dot gnu.org
  2021-12-14  5:26 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vanyacpp at gmail dot com @ 2021-04-11 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100039
           Summary: GCC can not bind lvalue to lvalue reference in
                    brace-initialized-temporary expression
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vanyacpp at gmail dot com
  Target Milestone: ---

Consider this program:

typedef int& ref;

int main()
{
    int a;
    ref{a};
}

This is accepted by clang, msvc and icc. GCC 10.3 rejects this code with a
message:

error: cannot bind non-const lvalue reference of type 'ref' {aka 'int&'} to an
rvalue of type 'int'

I believe the error message is incorrect, because "a" is not an rvalue here. It
is lvalue, therefore it should be allowed to bind to lvalue reference.

https://godbolt.org/z/TWY9GPq3E

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

* [Bug c++/100039] GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression
  2021-04-11 23:45 [Bug c++/100039] New: GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression vanyacpp at gmail dot com
@ 2021-04-12  0:06 ` mpolacek at gcc dot gnu.org
  2021-12-14  5:26 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-12  0:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-04-12
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Not a regression.

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

* [Bug c++/100039] GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression
  2021-04-11 23:45 [Bug c++/100039] New: GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression vanyacpp at gmail dot com
  2021-04-12  0:06 ` [Bug c++/100039] " mpolacek at gcc dot gnu.org
@ 2021-12-14  5:26 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14  5:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 77875.

*** This bug has been marked as a duplicate of bug 77875 ***

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

end of thread, other threads:[~2021-12-14  5:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11 23:45 [Bug c++/100039] New: GCC can not bind lvalue to lvalue reference in brace-initialized-temporary expression vanyacpp at gmail dot com
2021-04-12  0:06 ` [Bug c++/100039] " mpolacek at gcc dot gnu.org
2021-12-14  5:26 ` pinskia 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).