[Boost-bugs] [Boost C++ Libraries] #10975: The name exception is ambiguous, exception and std::exception.

Subject: [Boost-bugs] [Boost C++ Libraries] #10975: The name exception is ambiguous, exception and std::exception.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-28 05:26:53


#10975: The name exception is ambiguous, exception and std::exception.
------------------------------+--------------------------------
 Reporter: Sergey.Sprogis@… | Owner: grafik
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: Regression Testing
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+--------------------------------
 1. Description of the failure.

 On Solaris 11.2 Oracle Studio 12.4 C++ compiler under -std=c++11 option
 produces the following error messages for
 libs/spirit/classic/test/match_tests.cpp test.

 "/usr/include/math.h", line 215: Error: The name exception is ambiguous,
 exception and std::exception.
 "/usr/include/math.h", line 215: Error: The name exception is ambiguous,
 exception and std::exception.
 ".../boost/exception/exception.hpp", line 140: Error: The name exception
 is ambiguous, exception and std::exception.


 and actually it produces similar error messages for small test like this:

  namespace boost {
   class exception;
  }
  using namespace boost;
  #include <algorithm>

 or like this:

  class exception;
  using namespace std;
  #include <algorithm>

 Note that in the original boost harness "class exception;" can be found
 inside: boost/exception/exception.hpp

 2. Cause of the failure.


 This is a C++ vs Unix or Boost vs Unix issue.

 Standard Unix requires "struct exception" in the global namespace when
 <math.h> is included. This conflicts with std::exception or
 boost::exception,
 but only when there are using-declarations or using-directives that bring
 std::exception or boost::exception into the global namespace.

 When <math.h> is included, user code must avoid all of the following at
 file
 scope (in the global namespace):
 using namespace std;
 using namespace boost;
 using std::exception;
 using boost::exception;

 3. Possible Solution.

  - Remove line:

      using namespace std;

  - Replace all 'cout' invocations with 'std::cout'

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10975>
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:17 UTC