Bug 1542132

Summary: ambiguous overload for 'operator!=' for 'std::error_code's
Product: [Fedora] Fedora Reporter: Marek Skalický <mskalick>
Component: gccAssignee: Jonathan Wakely <jwakely>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: rawhideCC: aoliva, davejohansen, fweimer, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-12 11:43:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
compile errors none

Description Marek Skalický 2018-02-05 16:12:05 UTC
Created attachment 1391605 [details]
compile errors

Description of problem:
I have FTBFS mongodb error in Fedora Rawhide (now combined with unresolvable dependencies error). Based on koschei information [1] I think this problem is caused by gcc 8 update.

Error is in bundled asio library.

I can see similar error messages:

src/third_party/asio-master/asio/include/asio/basic_socket_streambuf.hpp:463:15: error: ambiguous overload for 'operator!=' (operand types are 'asio::error_code' {aka 'std::error_code'} and 'asio::error::basic_errors')
       if (ec_ != asio::error::would_block
           ~~~~^~~~~~~

/usr/include/c++/8/system_error:319:3: note: candidate: 'bool std::operator!=(const std::error_code&, const std::error_code&)'
   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
   ^~~~~~~~
/usr/include/c++/8/system_error:323:3: note: candidate: 'bool std::operator!=(const std::error_code&, const std::error_condition&)'
   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
   ^~~~~~~~
/usr/include/c++/8/system_error:327:3: note: candidate: 'bool std::operator!=(const std::error_condition&, const std::error_code&)'
   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
   ^~~~~~~~
/usr/include/c++/8/system_error:331:3: note: candidate: 'bool std::operator!=(const std::error_condition&, const std::error_condition&)'
   operator!=(const error_condition& __lhs,
   ^~~~~~~~


But code below is defined and is_error_condition_enum isn't defined!

namespace std {

template<> struct is_error_code_enum<asio::error::basic_errors>
{
  static const bool value = true;
};
}

Used asio code can be browsed in [2]. IMHO related code is in asio/include/asio/error_code.hpp and asio/include/asio/error.hpp (ASIO_HAS_STD_SYSTEM_ERROR is defined). I was trying to separate a reproducer, but I wasn't successful.

What's wrong? What changed in gcc8?

Version-Release number of selected component (if applicable):
gcc-c++-8.0.1-0.9.fc28.x86_64
libstdc++-8.0.1-0.9.fc28.x86_64

How reproducible:
Always in Fedora Rawhide when building mongodb package.

Steps to Reproduce:
1. 'fedpkg prep' for mongodb package (master branch in rawhide OS)
2. dnf builddep for mongodb
3. in unpacked source run 'scons-3 build/fedora/mongo/executor/network_interface_asio_operation.o $(cat build-options)'

Actual results:
In attached log.

Expected results:
No 'error: ambiguous overload for 'operator!=''

Additional info:
[1] https://apps.fedoraproject.org/koschei/package/mongodb?collection=f28 check from 2018-01-30 11:44:02
[2] https://github.com/mongodb/mongo/tree/v3.6/src/third_party/asio-master

Comment 1 Marek Skalický 2018-02-08 14:16:26 UTC
Any idea how to workaround this?

Comment 2 Jonathan Wakely 2018-02-08 14:40:16 UTC
Reduced:

#include <system_error>

namespace asio { namespace error {
  struct basic_errors { };

  std::error_code make_error_code(basic_errors);
} }

namespace std {

template<> struct is_error_code_enum<asio::error::basic_errors> : true_type { };
}

template<typename> struct Y { };

template<typename T>
struct X : Y<T> {
  void f()
  {
    std::error_code ec;
    asio::error::basic_errors err;
    ec == err;
  }
};

This is the same GCC bug as Bug 1542254 and I don't know a workaround.

Comment 3 Jonathan Wakely 2018-02-09 20:37:43 UTC
This has now been fixed upstream, so should get fixed next time GCC is updated in rawhide.

Comment 4 Marek Skalický 2018-02-12 11:43:14 UTC
Jonathan, thanks for solving this problem.

It is fixed in gcc-8.0.1-0.13.fc28.