Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build with boost >= 1.87.0 #596

Open
berolinux opened this issue Dec 13, 2024 · 5 comments
Open

Fails to build with boost >= 1.87.0 #596

berolinux opened this issue Dec 13, 2024 · 5 comments

Comments

@berolinux
Copy link

libzypp fails to build with boost 1.87.0 (1.86 is ok) because some pointer types sent to an iostream are now considered ambiguous.

@tomop-tg
Copy link

The same problem occurred in my environment.

  • gcc 12.2
  • boost 1.87.0

The error messages was as follows:

/home/myuser/rpm/BUILD/libzypp-17.35.15/zypp-core/base/PtrTypes.h:159:16: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const boost::shared_ptr<void>')
  159 |   { return str << obj; }
      |            ~~~ ^~ ~~~
      |            |      |
      |            |      const boost::shared_ptr<void>
      |            std::ostream {aka std::basic_ostream<char>}
/home/myuser/rpm/BUILD/libzypp-17.35.15/zypp-core/base/PtrTypes.h:141:25: note: candidate: 'std::ostream& std::operator<<(ostream&, const boost::shared_ptr<X>&) [with D = void; ostream = basic_ostream<char>]'
  141 |   inline std::ostream & operator<<( std::ostream & str, const zypp::shared_ptr<void> & obj )
      |                         ^~~~~~~~
In file included from /usr/include/boost/shared_ptr.hpp:17,
                 from /home/myuser/rpm/BUILD/libzypp-17.35.15/zypp-core/base/PtrTypes.h:21:
/usr/include/boost/smart_ptr/shared_ptr.hpp:778:34: note: candidate: 'std::ostream& boost::operator<<(std::ostream&, const shared_ptr<X>&) [with Y = void; std::ostream = std::basic_ostream<char>]'
  778 | template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p)
      |                                  ^~~~~~~~
gmake[2]: *** [zypp/CMakeFiles/zypp-objlib.dir/build.make:149: zypp/CMakeFiles/z
ypp-objlib.dir/pool/PoolStats.cc.o] Error 1

@berolinux
Copy link
Author

The problem is that the std::ostream & operator << overloads in zypp-core/base/PtrTypes.h clash with the similar std::ostream & operator << overloads added in boost 1.87.0's boost/smart_ptr/shared_ptr.hpp

@berolinux
Copy link
Author

Unless I'm overlooking something, there is no simple fix because boost's overloads and libzypp's are equally specialised, so there's no sane way to pick one over another -- so as a quick "fix", I've added a little patch to boost https://github.com/OpenMandrivaAssociation/boost/blob/master/boost-1.87.0-hack-for-libzypp-compatibility.patch and am building libzypp with -DBOOST_POINTERS_NO_IOSTREAM.
Not very nice, but effective (and since the iostream stuff is implemented inline in the headers, there won't be a symbol clash).

@gruenich
Copy link
Contributor

gruenich commented Jan 2, 2025

Weird, the error message mentions two functions from libzypp and Boost. Both are more or less unchanged for more than a decade. There is no obvious recent change causing this problem.

@tomop-tg
Copy link

This problem seems to have been solved by boostorg/smart_ptr@e7433ba .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants