public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98995] New: Copy elision not applied to members declared with [[no_unique_address]]
@ 2021-02-08  0:53 david at doublewise dot net
  2021-02-08  9:36 ` [Bug c++/98995] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: david at doublewise dot net @ 2021-02-08  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98995
           Summary: Copy elision not applied to members declared with
                    [[no_unique_address]]
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at doublewise dot net
  Target Milestone: ---

The following valid translation unit is rejected by gcc 11:

```
struct non_movable {
        non_movable() = default;
        non_movable(non_movable &&) = delete;
};

struct wrapper {
        constexpr explicit wrapper(auto function):
                m(function())
        {
        }

        [[no_unique_address]] non_movable m;
};

constexpr auto w = wrapper{[]{ return non_movable(); }};
```

with the error message

```
<source>: In instantiation of 'constexpr wrapper::wrapper(auto:1) [with auto:1
= <lambda()>]':
<source>:15:55:   required from here
<source>:8:17: error: use of deleted function
'non_movable::non_movable(non_movable&&)'
    8 |                 m(function())
      |                 ^~~~~~~~~~~~~
<source>:3:9: note: declared here
    3 |         non_movable(non_movable &&) = delete;
      |         ^~~~~~~~~~~
Compiler returned: 1
```

See it live: https://godbolt.org/z/o1TbY9

This was accepted in gcc 10.2.

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

end of thread, other threads:[~2023-10-27 13:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08  0:53 [Bug c++/98995] New: Copy elision not applied to members declared with [[no_unique_address]] david at doublewise dot net
2021-02-08  9:36 ` [Bug c++/98995] [11 Regression] " rguenth at gcc dot gnu.org
2021-02-08 12:15 ` redi at gcc dot gnu.org
2021-02-08 20:37 ` jason at gcc dot gnu.org
2021-04-27 11:40 ` [Bug c++/98995] [11/12 " jakub at gcc dot gnu.org
2021-07-28  7:05 ` rguenth at gcc dot gnu.org
2022-04-21  7:48 ` rguenth at gcc dot gnu.org
2022-04-28 15:12 ` [Bug c++/98995] [11/12/13 " davidfromonline at gmail dot com
2023-01-08  6:45 ` pinskia at gcc dot gnu.org
2023-01-08  6:46 ` [Bug c++/98995] [10/11/12/13 " pinskia at gcc dot gnu.org
2023-01-10 21:35 ` [Bug c++/98995] [10/11/12/13 Regression] Copy elision not applied to members declared with [[no_unique_address]] or a empty base class pinskia at gcc dot gnu.org
2023-02-06 14:20 ` redi at gcc dot gnu.org
2023-02-13 16:12 ` pinskia at gcc dot gnu.org
2023-06-30 20:09 ` [Bug c++/98995] [10/11/12/13/14 " pinskia at gcc dot gnu.org
2023-07-07 10:39 ` [Bug c++/98995] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-10-27 13:55 ` jan.kokemueller at gmail dot com

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).