I have written code that compiles fine on GCC 6.2, clang 3.9, and MSVS 2015 (the C++ build tools version).
It's available on github:
https://www.github.com/rubenvb/skui
Build with the following define to skip building Skia and head straight for the error:
cmake -DSKIP_SKIA -DCMAKE_CXX_COMPILER=icpc make
The error is as follows:
/home/ruben/Development/skui/core/value_ptr.h++(50): error: object of abstract class type "skui::core::implementation::slot<void>" is not allowed: function "skui::core::implementation::slot<ReturnType, ArgTypes...>::operator() [with ReturnType=void, ArgTypes=<>]" is a pure virtual function { return static_cast<void*>(new T(*static_cast<T*>(other))); }; ^ detected during: instantiation of "void *(*skui::core::copy_constructor_copier<T>())(void *) [with T=skui::core::implementation::slot<void>]" at line 69 instantiation of "skui::core::smart_copy<T>::smart_copy() [with T=skui::core::implementation::slot<void>]" at line 140 /home/ruben/Development/skui/core/value_ptr.h++(59): error: static assertion failed with "Cannot default construct smart_copy for an abstract type." explicit smart_copy() { static_assert(!std::is_abstract<T>::value, "Cannot default construct smart_copy for an abstract type."); } ^ detected during instantiation of "skui::core::smart_copy<T>::smart_copy() [with T=skui::core::implementation::slot<void>]" at line 140 /home/ruben/Development/skui/core/value_ptr.h++(50): error: object of abstract class type "skui::core::implementation::slot<void, skui::core::string>" is not allowed: function "skui::core::implementation::slot<ReturnType, ArgTypes...>::operator() [with ReturnType=void, ArgTypes=<skui::core::string>]" is a pure virtual function { return static_cast<void*>(new T(*static_cast<T*>(other))); }; ^ detected during: instantiation of "void *(*skui::core::copy_constructor_copier<T>())(void *) [with T=skui::core::implementation::slot<void, skui::core::string>]" at line 69 instantiation of "skui::core::smart_copy<T>::smart_copy() [with T=skui::core::implementation::slot<void, skui::core::string>]" at line 140 instantiation of class "skui::core::value_ptr<T, Copier, Deleter> [with T=skui::core::implementation::slot<void, skui::core::string>, Copier=skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, Deleter=std::default_delete<skui::core::implementation::slot<void, skui::core::string>>]" at line 72 of "/usr/include/c++/6.2.1/bits/list.tcc" instantiation of "void std::__cxx11::_List_base<_Tp, _Alloc>::_M_clear() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 442 of "/usr/include/c++/6.2.1/bits/stl_list.h" instantiation of "std::__cxx11::_List_base<_Tp, _Alloc>::~_List_base() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" implicit generation of "std::__cxx11::list<_Tp, _Alloc>::~list() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" instantiation of class "std::__cxx11::list<_Tp, _Alloc> [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" instantiation of "skui::core::implementation::signal_base<ArgTypes...>::~signal_base() [with ArgTypes=<skui::core::string>]" at line 191 of "/home/ruben/Development/skui/core/signal.h++" /home/ruben/Development/skui/core/value_ptr.h++(59): error: static assertion failed with "Cannot default construct smart_copy for an abstract type." explicit smart_copy() { static_assert(!std::is_abstract<T>::value, "Cannot default construct smart_copy for an abstract type."); } ^ detected during: instantiation of "skui::core::smart_copy<T>::smart_copy() [with T=skui::core::implementation::slot<void, skui::core::string>]" at line 140 instantiation of class "skui::core::value_ptr<T, Copier, Deleter> [with T=skui::core::implementation::slot<void, skui::core::string>, Copier=skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, Deleter=std::default_delete<skui::core::implementation::slot<void, skui::core::string>>]" at line 72 of "/usr/include/c++/6.2.1/bits/list.tcc" instantiation of "void std::__cxx11::_List_base<_Tp, _Alloc>::_M_clear() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 442 of "/usr/include/c++/6.2.1/bits/stl_list.h" instantiation of "std::__cxx11::_List_base<_Tp, _Alloc>::~_List_base() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" implicit generation of "std::__cxx11::list<_Tp, _Alloc>::~list() [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" instantiation of class "std::__cxx11::list<_Tp, _Alloc> [with _Tp=std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>, _Alloc=std::allocator<std::pair<const skui::core::trackable *, skui::core::value_ptr<skui::core::implementation::slot<void, skui::core::string>, skui::core::smart_copy<skui::core::implementation::slot<void, skui::core::string>>, std::default_delete<skui::core::implementation::slot<void, skui::core::string>>>>>]" at line 62 of "/home/ruben/Development/skui/core/signal.h++" instantiation of "skui::core::implementation::signal_base<ArgTypes...>::~signal_base() [with ArgTypes=<skui::core::string>]" at line 191 of "/home/ruben/Development/skui/core/signal.h++" compilation aborted for /home/ruben/Development/skui/core/application.c++ (code 2)
I have absolutely no idea why it fails, and the fact that three other independent compilers like the code as it is (with /W4 or -Wextra -pedantic warning free) points me in the direction of a compiler bug. Am I right or is there a subtlety in the code I have written?
Thread Topic:
Bug Report