From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1254 invoked by alias); 10 Apr 2012 08:15:37 -0000 Received: (qmail 1238 invoked by uid 22791); 10 Apr 2012 08:15:35 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,SUBJ_OBFU_PUNCT_FEW X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Apr 2012 08:15:22 +0000 From: "jpr at essi dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52924] New: Using an std::function object as deleter of shared_ptr in C++0x mode does not compile Date: Tue, 10 Apr 2012 08:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jpr at essi dot fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00593.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52924 Bug #: 52924 Summary: Using an std::function object as deleter of shared_ptr in C++0x mode does not compile Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: jpr@essi.fr The following program fails to compile in C++0X mode : #include #include class A {}; A a; void fdeleter(A *pa) {} std::function deleter =3D fdeleter; std::shared_ptr spa(&a, deleter); int main() {} Note that - replacing deleter by fdeleter (or a lambda) in spa definition works; - compiling in non-c++0x mode (replacing std by std::tr1 works as well - this program compiles OK in c++0x mode with gcc-4.6.x gcc-version : gcc-4.7.0 (64 bits) system : Linux Fedora 15 (64 bits) gcc configuration: (gcc -v) Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/local/test/gcc-4.7.0/libexec/gcc/x86_64-unknown-= linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=3D/usr/local/test/gcc-4.7.0 --with-local-prefix=3D/usr/local/test/gcc-4.7.0 --enable-threads --enable-languages=3Dada,c,c++,fortran,java,objc,obj-c++ --with-gmp-lib=3D/usr/lib64 --with-mpfr-lib=3D/usr/lib64 --with-mpc-lib=3D/= usr/lib64 --disable-multilib Thread model: posix gcc version 4.7.0 (GCC)=20 Compilation command and compiler output: g++ -g -Wall -Wextra -std=3Dc++0x -o deleter-bug-c++0x deleter-bug-c++0x.cpp deleter-bug-c++0x.cpp:7:6: warning: unused parameter =E2=80=98pa=E2=80=99 [= -Wunused-parameter] In file included from /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr.h:52:0, from /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/memory:87, from deleter-bug-c++0x.cpp:1: /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr_base.h: In instantiation of =E2=80=98class std::_Sp_counted_deleter, std::allocator, (__gnu_cxx::_Lock_policy)2u>= =E2=80=99: /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr_base.h:474:8: required from =E2=80=98std::__shared_count<_Lp>::__shared_count(_Ptr, _De= leter) [with _Ptr =3D A*; _Deleter =3D std::function; __gnu_cxx::_Lock_policy = _Lp =3D (__gnu_cxx::_Lock_policy)2u]=E2=80=99 /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr_base.h:776:37: required from =E2=80=98std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*, _= Deleter) [with _Tp1 =3D A; _Deleter =3D std::function; _Tp =3D A; __gnu_cxx::_Lock_policy _Lp =3D (__gnu_cxx::_Lock_policy)2u]=E2=80=99 /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr.h:130:37: required from =E2=80=98std::shared_ptr<_Tp>::shared_ptr(_Tp1*, _Deleter) = [with _Tp1 =3D A; _Deleter =3D std::function; _Tp =3D A]=E2=80=99 deleter-bug-c++0x.cpp:10:35: required from here /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr_base.h:324:11: error: looser throw specifier for =E2=80=98virtual std::_Sp_counted_deleter= , std::allocator, (__gnu_cxx::_Lock_policy)2u>::~_Sp_counted_deleter()=E2=80=99 /usr/local/test/gcc-4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../.= ./include/c++/4.7.0/bits/shared_ptr_base.h:116:7: error: overriding =E2=80=98std::_Sp_counted_base<_Lp>::~_Sp_counted_base(= ) noexcept (true) [with __gnu_cxx::_Lock_policy _Lp =3D (__gnu_cxx::_Lock_policy)2u]= =E2=80=99 Compilation exited abnormally with code 1 at Tue Apr 10 10:00:29