boost-ext / di

C++14 Dependency Injection Library
https://boost-ext.github.io/di
1.13k stars 137 forks source link

Can't compile with gcc 10 #469

Closed JulZimmermann closed 3 years ago

JulZimmermann commented 4 years ago

Expected Behavior

Expected to compile.

Actual Behavior

Can't compile the quick guide example (or any other application using boost::di) with the gcc 10 compiler

Error Message:

<source>: In member function 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>::create() const':

<source>:2575:77: error: 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>::create() const' is deprecated: creatable constraint not satisfied [-Werror=deprecated-declarations]

 2575 |     return __BOOST_DI_TYPE_WKND(type) create_impl<aux::true_type>(aux::type<type>{});

      |                                                                             ^~~~

<source>:2571:3: note: declared here

 2571 |   create()

      |   ^~~~~~

<source>: In member function 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>::create() const':

<source>:2803:77: error: 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>::create() const' is deprecated: creatable constraint not satisfied [-Werror=deprecated-declarations]

 2803 |     return __BOOST_DI_TYPE_WKND(type) create_impl<aux::true_type>(aux::type<type>{});

      |                                                                             ^~~~

<source>:2799:3: note: declared here

 2799 |   create()

      |   ^~~~~~

cc1plus: some warnings being treated as errors

Compiler returned: 1

Steps to Reproduce the Problem

  1. Use gcc 10 compiler
  2. compile the example

Here is a Compiler Explorer link showing the problem: https://godbolt.org/z/xvHTfd By switching the compiler to gcc 9.3 the code compiles just fine.

Specifications

krzysztof-jusiak commented 4 years ago

Hmm, it seems like a GCC bug to me, it tries to eagerly instantiate create function for template<class...> which shouldn't even match the overload set and bails out on the deprecated warning

After commenting the warning it seems to work :thinking: https://godbolt.org/z/shDx7e

Needs some more digging, though :bug:

JulZimmermann commented 4 years ago

Any update on this? It's really sad not to be able to use GCC 10 because of this 😕

As a workaround, I defined __BOOST_DI_DEPRECATED with nothing. Are there any drawbacks to this?

AnatoliyYakimov commented 3 years ago

Still getting this error with Msys2 MinGW 9.3.0 (x86_64-w64-mingw32/9.3.0). Defining __BOOST_DI_DEPRECATED as nothing helps, but this is not good solution still.

JulZimmermann commented 3 years ago

Meanwhile I think the problem is bigger then GCC 10 (and apparently mingw 9) support.

Undefining __BOOST_DI_DEPRECATED helped me with the error messages when forgeting to register a type. With __BOOST_DI_DEPRECATED I always get obscure template creation error messages similar to the one in my first post. Without it, the compiler gives a straight 2 line message about the missing type.

So, I think there is a problem with __BOOST_DI_DEPRECATED in general. I will keep define it as nothing.

krzysztof-jusiak commented 3 years ago

Should be fixed now -> https://godbolt.org/z/E7xzxE by https://github.com/krzysztof-jusiak/di/commit/732b7d2af76e80c57ea9c40ee74aaf3a4e7013cf

mloskot commented 2 years ago

Hmm, it seems like a GCC bug to me

For the archive records, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95302