[Boost-bugs] [Boost C++ Libraries] #6655: Inclusion of <boost/signals2.hpp> causes valid code to fail to compile with Clang

Subject: [Boost-bugs] [Boost C++ Libraries] #6655: Inclusion of <boost/signals2.hpp> causes valid code to fail to compile with Clang
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-06 10:02:13


#6655: Inclusion of <boost/signals2.hpp> causes valid code to fail to compile with
Clang
---------------------------------------------------------+------------------
 Reporter: Alexander Korsunsky <fat.lobyte9@…> | Owner: fmhess
     Type: Bugs | Status: new
Milestone: Boost 1.50.0 | Component: signals2
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
---------------------------------------------------------+------------------
 The following well-formed program does not compile with Clang 3.1 (from
 trunk):

 {{{
 #include <memory>
 #include <boost/signals2.hpp>

 int main()
 {
     std::shared_ptr<int> s;
 }
 }}}

 The error message is:
 {{{
 signals2-bug.cpp:6:26: error: implicit instantiation of undefined template
       'std::shared_ptr<int>'
     std::shared_ptr<int> s;
                          ^
 /home/alexander/usr/local/include/boost/signals2/detail/foreign_ptr.hpp:24:30:
 note:
       template is declared here
   template<typename T> class shared_ptr;
                              ^
 }}}

 The header boost/signals2/detail/foreign_ptr.hpp declares two names in the
 std:: namespace:
 {{{
 #if !defined(BOOST_INTEL_STDCXX0X)
 namespace std
 {
   template<typename T> class shared_ptr;
   template<typename T> class weak_ptr;
 }
 #endif
 }}}

 which is undefined behaviour, according to the Standard 17.6.4.2.1:
   The behavior of a C++ program is undefined if it adds declarations or
 definitions to namespace std or to a
   namespace within namespace std unless otherwise specified. A program may
 add a template specialization
   for any standard library template to namespace std only if the
 declaration depends on a user-defined type
   and the specialization meets the standard library requirements for the
 original template and is not explicitly
   prohibited.

 The compilation succeeds, if either the #include of <boost/signals2.hpp>
 is removed, or the offending lines are commented out.

 Please remove the offending lines from the header.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6655>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC