Bug 44708 - Enabling -std=c++0x results in ambiguous function overload in <ext/algorithm> header
Summary: Enabling -std=c++0x results in ambiguous function overload in <ext/algorithm>...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.4.2
: P3 normal
Target Milestone: 4.5.1
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-29 08:10 UTC by Alexander Dubov
Modified: 2010-06-29 10:04 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-06-29 09:15:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Dubov 2010-06-29 08:10:24 UTC
The example program below will exhibit the problem when compiled with -std=c++0x or gnu++0x flag. The fix appears to be trivial, but requires a change to <ext/algorithm> header.

Example program:
#include <iostream>
#include <ext/rope>

using namespace std;

int main(int argc, char **argv)
{
	__gnu_cxx::crope line("test-test-test");

	cout << line.c_str() << endl;
	return 0;
}

Compilation error message:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/ropeimpl.h:48,                                                                  
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/rope:2956,                                                                      
                 from testrope.cpp:2:                                           
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/algorithm: In function &#8216;std::pair<_InputIter, _ForwardIter> __gnu_cxx::copy_n(_InputIterator, _Size, _OutputIterator) [with _InputIterator = char*, _Size = long unsigned int, _OutputIterator = char*]&#8217;:                                                             
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/ropeimpl.h:1090:   instantiated from &#8216;static _CharT* __gnu_cxx::rope<_CharT, _Alloc>::_S_flatten(__gnu_cxx::_Rope_RopeRep<_CharT, _Alloc>*, _CharT*) [with _CharT = char, _Alloc = std::allocator<char>]&#8217;
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/ropeimpl.h:1621:   instantiated from &#8216;const _CharT* __gnu_cxx::rope<_CharT, _Alloc>::c_str() const [with _CharT = char, _Alloc = std::allocator<char>]&#8217;
testrope.cpp:10:   instantiated from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/algorithm:127: error: call of overloaded &#8216;__copy_n(char*&, long unsigned int&, char*&, std::random_access_iterator_tag)&#8217; is ambiguous
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/algorithm:78: note: candidates are: std::pair<_InputIter, _ForwardIter> __gnu_cxx::__copy_n(_InputIterator, _Size, _OutputIterator, std::input_iterator_tag) [with _InputIterator = char*, _Size = long unsigned int, _OutputIterator = char*]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/ext/algorithm:93: note:                 std::pair<_InputIter, _ForwardIter> __gnu_cxx::__copy_n(_RAIterator, _Size, _OutputIterator, std::random_access_iterator_tag) [with _RAIterator = char*, _Size = long unsigned int, _OutputIterator = char*]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/bits/stl_algo.h:1003: note:                 _OutputIterator std::__copy_n(_RandomAccessIterator, _Size, _OutputIterator, std::random_access_iterator_tag) [with _RandomAccessIterator = char*, _Size = long unsigned int, _OutputIterator = char*]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.2/include/g++-v4/bits/stl_algo.h:988: note:                 _OutputIterator std::__copy_n(_InputIterator, _Size, _OutputIterator, std::input_iterator_tag) [with _InputIterator = char*, _Size = long unsigned int, _OutputIterator = char*]
Comment 1 Paolo Carlini 2010-06-29 09:15:47 UTC
Fixing momentarily, thanks.
Comment 2 paolo@gcc.gnu.org 2010-06-29 10:04:03 UTC
Subject: Bug 44708

Author: paolo
Date: Tue Jun 29 10:03:36 2010
New Revision: 161524

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161524
Log:
2010-06-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/44708
	* include/ext/algorithm (copy_n): Qualify __copy_n call with
	__gnu_cxx::
	* testsuite/ext/rope/44708.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/ext/rope/44708.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/ext/algorithm

Comment 3 paolo@gcc.gnu.org 2010-06-29 10:04:25 UTC
Subject: Bug 44708

Author: paolo
Date: Tue Jun 29 10:04:01 2010
New Revision: 161525

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161525
Log:
2010-06-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/44708
	* include/ext/algorithm (copy_n): Qualify __copy_n call with
	__gnu_cxx::
	* testsuite/ext/rope/44708.cc: New.

Added:
    branches/gcc-4_5-branch/libstdc++-v3/testsuite/ext/rope/44708.cc
Modified:
    branches/gcc-4_5-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_5-branch/libstdc++-v3/include/ext/algorithm

Comment 4 Paolo Carlini 2010-06-29 10:04:45 UTC
Fixed.