public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106489] New: Valid Code involving assignment rejected by gcc
@ 2022-07-31  7:12 jlame646 at gmail dot com
  2022-07-31  7:17 ` [Bug c++/106489] " jlame646 at gmail dot com
  2022-07-31  8:50 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2022-07-31  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106489
           Summary: Valid Code involving assignment rejected by gcc
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following valid code is rejected by gcc. https://godbolt.org/z/z9MKfz3e8

```
class A{
// implicitly generated assignment operations
};

int main() {
// ... 
A& a = A{} = A{};
}
```
Error says:

```
<source>:7:12: error: cannot bind non-const lvalue reference of type 'A&' to an
rvalue of type 'A'
    7 | A& a = A{} = A{};
      |        ~~~~^~~~~
```

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

* [Bug c++/106489] Valid Code involving assignment rejected by gcc
  2022-07-31  7:12 [Bug c++/106489] New: Valid Code involving assignment rejected by gcc jlame646 at gmail dot com
@ 2022-07-31  7:17 ` jlame646 at gmail dot com
  2022-07-31  8:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2022-07-31  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Liam <jlame646 at gmail dot com> changed:

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

--- Comment #1 from Jason Liam <jlame646 at gmail dot com> ---
This has already been fixed in GCC 11.3 Demo: https://godbolt.org/z/Wo95GadsK

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

* [Bug c++/106489] Valid Code involving assignment rejected by gcc
  2022-07-31  7:12 [Bug c++/106489] New: Valid Code involving assignment rejected by gcc jlame646 at gmail dot com
  2022-07-31  7:17 ` [Bug c++/106489] " jlame646 at gmail dot com
@ 2022-07-31  8:50 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-31  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |DUPLICATE

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed by r12-6862

    c++: assignment to temporary [PR59950]

    Given build_this of a TARGET_EXPR, cp_build_fold_indirect_ref returns the
    TARGET_EXPR.  But that's the wrong value category for the result of the
    defaulted class assignment operator, which returns an lvalue, so we need to
    actually build the INDIRECT_REF.

            PR c++/59950

    gcc/cp/ChangeLog:

            * call.cc (build_over_call): Use cp_build_indirect_ref.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/assign2.C: New test.

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

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

end of thread, other threads:[~2022-07-31  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31  7:12 [Bug c++/106489] New: Valid Code involving assignment rejected by gcc jlame646 at gmail dot com
2022-07-31  7:17 ` [Bug c++/106489] " jlame646 at gmail dot com
2022-07-31  8:50 ` 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).