Why does this fail to compile in C++11 mode?

Jonathan Wakely jwakely.gcc@gmail.com
Mon Jun 10 11:39:00 GMT 2013


On 10 June 2013 05:37, Kenny Simpson wrote:
> A few more data points:
>
> In c++11 mode, cstdio pulls in ::remove, but in c++98 mode, including <algorithm> doesn't pull in <cstdio>

Yes, looking at the preprocessed output I'd noticed 'using ::remove;'
but hadn't realised it wasn't present in the c++98 version.

> Changing the template instantiation to:
> template iterator_type remove<>(iterator_type, iterator_type, const X&);
>
> or
>
> template iterator_type remove<iterator_type, X>(iterator_type, iterator_type, const X&);
>
> makes it happy.

Thanks for doing the legwork, Kenny, I think you've solved it.  This
reproduces the error:

namespace std
{
  template<typename T, typename U>
    void remove(T, U)
    { }
}

int remove(char);

namespace std
{
  using ::remove;
}

namespace std
{
  template void remove(int, long);
}

Reversing the order of the two remove declarations makes it compile,
so I think this is a G++ bug.



More information about the Libstdc++ mailing list