boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
101 stars 113 forks source link

Comparing strings does not compile in gcc 7+ in C++17 mode #58

Closed akrzemi1 closed 6 years ago

akrzemi1 commented 6 years ago

The following program does not compile in GCC 7, in C++17 mode:

#include <boost/container/string.hpp>

int main()
{
    boost::container::string s1, s2;
    return s1 == s2;
}

This might be a bug in GCC (it works in clang), but I am not sure. It boils to the following situation, which does not compile in GCC 7 (C++17):

template <class T, class U = int>
    class C
    {};

template <class T, class U>
    void f(const C<T, U>&) {}

template <class T, template <class> class CT>
    void f(CT<T>) {}

int main()
{
    C<int> s;
    f(s);
}
igaztanaga commented 6 years ago

This looks like a compiler bug, because an exact match is availablein the overload set, so I don't get why is ambiguous. Also, in C++14 mode code compiles fine.

igaztanaga commented 6 years ago

I'll try to commit soon a patch to SFINAE out the string view overload, which is not a bad idea in general to avoid ambiguities.

akrzemi1 commented 6 years ago

I got the following background information on isocpp.org: https://groups.google.com/a/isocpp.org/d/topic/std-discussion/B1MHPRMqfFA/discussion

igaztanaga commented 6 years ago

Thanks, for the DR link. So it's time to patch the implementation...

akrzemi1 commented 6 years ago

One more link that might be useful: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82579 GCC developers say that the new rules for template-tempate argument matching have a regression in the Standard that they are forced to implement the regression too, but there is a flag in GCC to disable the feature: -fno-new-ttp-matching.

igaztanaga commented 6 years ago

I tested locally with Mingw-w64 GCC 7.1. Let me know if there are remaining issues. Thanks for all!

akrzemi1 commented 6 years ago

I only found it in Wandbox. I will not be able to test it until it is released. The source looks fine to me.