public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/116529] New: Construction of unique_ptr with reference type is rejected because of auto_ptr constructor
@ 2024-08-29  6:24 luigighiron at gmail dot com
  2024-08-29 10:17 ` [Bug libstdc++/116529] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: luigighiron at gmail dot com @ 2024-08-29  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116529
           Summary: Construction of unique_ptr with reference type is
                    rejected because of auto_ptr constructor
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luigighiron at gmail dot com
  Target Milestone: ---

When constructing a unique_ptr with a reference type an error will occur in the
libstdc++ implementation due to the auto_ptr constructor attempting to form a
pointer to the reference type. For example:

#include<memory>
int main(){
    struct deleter{
        using pointer=int*;
        void operator()(pointer p)const{
            delete p;
        }
    };
    std::unique_ptr<int&,deleter>u(new int);
}

libstdc++ rejects this program, libc++ and MSVC's STL allow it (when compiling
with C++17 or newer). The auto_ptr constructor was removed in C++17 along with
the rest of auto_ptr, this means that there shouldn't be any restrictions on
using a reference type when constructing a unique_ptr. I haven't seen any
restrictions on using a unique_ptr with a reference type so I assume that this
is OK (since C++17).

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

end of thread, other threads:[~2024-09-23 19:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-29  6:24 [Bug libstdc++/116529] New: Construction of unique_ptr with reference type is rejected because of auto_ptr constructor luigighiron at gmail dot com
2024-08-29 10:17 ` [Bug libstdc++/116529] " redi at gcc dot gnu.org
2024-08-29 10:22 ` redi at gcc dot gnu.org
2024-08-29 10:24 ` redi at gcc dot gnu.org
2024-08-30 10:43 ` redi at gcc dot gnu.org
2024-08-30 18:45 ` luigighiron at gmail dot com
2024-09-03 10:08 ` de34 at live dot cn
2024-09-03 13:45 ` redi at gcc dot gnu.org
2024-09-03 13:46 ` redi at gcc dot gnu.org
2024-09-20 22:50 ` cvs-commit at gcc dot gnu.org
2024-09-23 19:24 ` cvs-commit 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).