martinmoene / expected-dark

Expected objects for C++11 and later (and later perhaps C++98 )
MIT License
52 stars 4 forks source link

Breaks with clang-4.0 and higher. #8

Closed rnburn closed 7 years ago

rnburn commented 7 years ago

This code won't compile with clang:

#include "expected.hpp"
#include <system_error>

int main() {
  nonstd::expected<void, std::error_code> e1, e2;
  e2 = e1;
  return 0;
}

It gives the error message:

./expected.hpp:869:67: error: exception specification of 'swap' uses itself
        std::is_nothrow_move_constructible<E>::value && noexcept( swap( std::declval<E&>(), std::declv...
                                                                  ^
./expected.hpp:869:67: note: in instantiation of exception specification for 'swap' requested here
./expected.hpp:842:25: note: in instantiation of exception specification for 'swap' requested here
        expected( rhs ).swap( *this );
                        ^
main.cpp:6:6: note: in instantiation of member function 'nonstd::expected<void,
      std::__1::error_code>::operator=' requested here
  e2 = e1;
     ^
In file included from main.cpp:1:
./expected.hpp:869:93: error: too many arguments to function call, expected single argument 'rhs', have 2
      arguments
  ...&& noexcept( swap( std::declval<E&>(), std::declval<E&>() ) )
                  ~~~~                      ^~~~~~~~~~~~~~~~~~
./expected.hpp:867:5: note: 'swap' declared here
    void swap( expected & rhs ) noexcept
martinmoene commented 7 years ago

clang 3.5.0 still works, clang 3.6.0 breaks.