[LLVMbugs] [Bug 10455] New: Silent conversion of vector<T*>::iterator to vector<T*>::const_iterator&
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jul 23 06:02:01 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10455
Summary: Silent conversion of vector<T*>::iterator to
vector<T*>::const_iterator&
Product: libc++
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
AssignedTo: hhinnant at apple.com
ReportedBy: oroppas at gmail.com
CC: llvmbugs at cs.uiuc.edu
Hi,
The following piece of code cannot be compiled by either clang++/g++ with
libc++:
#include <vector>
#include <unordered_map>
typedef std::vector<int*> KernelVector;
typedef std::unordered_map<int*,KernelVector> KernelVectorMap;
int main()
{
KernelVectorMap::const_iterator kernel;
KernelVector::const_iterator subkernel = kernel->second.begin();
std::distance( kernel->second.begin(), subkernel );
return 0;
}
clang++ -std=c++0x -stdlib=libc++ ./const_iterator.cpp
./const_iterator.cpp:12:3: error: no matching function for call to 'distance'
std::distance( kernel->second.begin(), subkernel );
^~~~~~~~~~~~~
/usr/include/c++/v1/iterator:478:1: note: candidate template ignored: deduced
conflicting types for parameter
'_InputIter' ('std::__1::__wrap_iter<int **>' vs.
'std::__1::__wrap_iter<int *const *>')
distance(_InputIter __first, _InputIter __last)
^
1 error generated.
or
g++ -std=c++0x -I /usr/include/c++/v1/ ./const_iterator.cpp
./const_iterator.cpp: In function ‘int main()’:
./const_iterator.cpp:12:52: error: no matching function for call to
‘distance(std::__1::vector<int*>::iterator,
std::__1::vector<int*>::const_iterator&)’
./const_iterator.cpp:12:52: note: candidate is:
/usr/include/c++/v1/iterator:479:47: note: template<class _InputIter> typename
std::__1::iterator_traits::difference_type std::__1::distance(_InputIter,
_InputIter)
Can iterator be silently converted to const_iterator in the case like
std::distance()?
Please take a look at the comment by David Blaikie:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-July/016308.html
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list