fireblocks / mpc-lib

GNU General Public License v3.0
147 stars 86 forks source link

fix clang (macOS) compile error: object expression of non-scalar type cannot be used in a pseudo-destructor expression #28

Open kozyilmaz opened 1 month ago

kozyilmaz commented 1 month ago

clang on macOS spits out the following error during compilation. This PR wraps ed25519_scalar_t type with a struct

In file included from eddsa_offline_test.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream:43:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:222:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:23:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/allocator.h:172:12: error: object expression of non-scalar type 'unsigned char[32]' cannot be used in a pseudo-destructor expression
        __p->~_Tp();
        ~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/allocator_traits.h:315:13: note: in instantiation of member function 'std::allocator<unsigned char[32]>::destroy' requested here
        __a.destroy(__p);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:944:25: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<unsigned char[32]>>::destroy<unsigned char[32], void>' requested here
        __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
                        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:938:29: note: in instantiation of member function 'std::vector<unsigned char[32]>::__base_destruct_at_end' requested here
  void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:489:20: note: in instantiation of member function 'std::vector<unsigned char[32]>::__clear' requested here
            __vec_.__clear();
                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/exception_guard.h:86:7: note: in instantiation of member function 'std::vector<unsigned char[32]>::__destroy_vector::operator()' requested here
      __rollback_();
      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/exception_guard.h:137:10: note: in instantiation of member function 'std::__exception_guard_exceptions<std::vector<unsigned char[32]>::__destroy_vector>::~__exception_guard_exceptions' requested here
  return __exception_guard<_Rollback>(std::move(__rollback));
         ^
eddsa_offline_test.cpp:74:54: note: in instantiation of member function 'std::vector<unsigned char[32]>::vector' requested here
        _preprocessed_data.emplace(key_id, std::move(std::vector<ed25519_scalar_t>(size)));
                                                     ^
kozyilmaz commented 1 month ago

a similar version of the error can be found here: https://rextester.com/LAD69246