[LLVMbugs] [Bug 9540] New: Terrible recovery for broken default template argument
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 23 16:58:48 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9540
Summary: Terrible recovery for broken default template argument
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
The following code has a single mistake, but clang produces 6 errors and 5
instantiation notes:
$ cat ~/tmp/test.cc
#include <algorithm>
#include <iterator>
#include <vector>
struct my_iterator : std::iterator<std::output_iterator_tag, void
#ifdef CORRECT
, void, void, void
#endif
> {
my_iterator& operator++();
my_iterator& operator*();
template<typename T>
void operator=(T) {}
};
void foo() {
std::vector<int> v;
std::copy(v.begin(), v.end(), my_iterator());
}
$ clang++ -c ~/tmp/test.cc
In file included from /home/jyasskin/tmp/test.cc:1:
In file included from /usr/include/c++/4.4/algorithm:60:
In file included from /usr/include/c++/4.4/bits/stl_algobase.h:67:
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:102:63: error: cannot form
a reference
to 'void'
typename _Pointer = _Tp*, typename _Reference = _Tp&>
^
/home/jyasskin/tmp/test.cc:5:27: note: in instantiation of default argument for
'iterator<std::output_iterator_tag, void, long, void *>' required here
struct my_iterator : std::iterator<std::output_iterator_tag, void
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jyasskin/tmp/test.cc:1:
In file included from /usr/include/c++/4.4/algorithm:60:
In file included from /usr/include/c++/4.4/bits/stl_algobase.h:67:
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:126:35: error: no type
named
'iterator_category' in 'my_iterator'
typedef typename _Iterator::iterator_category iterator_category;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /home/jyasskin/tmp/test.cc:1:
In file included from /usr/include/c++/4.4/algorithm:60:
/usr/include/c++/4.4/bits/stl_algobase.h:389:24: note: in instantiation of
template class
'std::iterator_traits<my_iterator>' requested here
typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
^
/usr/include/c++/4.4/bits/stl_algobase.h:433:18: note: in instantiation of
function
template specialization 'std::__copy_move_a<false, int *, my_iterator>'
requested
here
return _OI(std::__copy_move_a<_IsMove>
^
/usr/include/c++/4.4/bits/stl_algobase.h:466:15: note: in instantiation of
function
template specialization 'std::__copy_move_a2<false,
__gnu_cxx::__normal_iterator<int
*, std::vector<int, std::allocator<int> > >, my_iterator>' requested here
return (std::__copy_move_a2<__is_move_iterator<_II>::__value>
^
/home/jyasskin/tmp/test.cc:18:3: note: in instantiation of function template
specialization 'std::copy<__gnu_cxx::__normal_iterator<int *,
std::vector<int,
std::allocator<int> > >, my_iterator>' requested here
std::copy(v.begin(), v.end(), my_iterator());
^
In file included from /home/jyasskin/tmp/test.cc:1:
In file included from /usr/include/c++/4.4/algorithm:60:
In file included from /usr/include/c++/4.4/bits/stl_algobase.h:67:
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:127:35: error: no type
named
'value_type' in 'my_iterator'
typedef typename _Iterator::value_type value_type;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:128:35: error: no type
named
'difference_type' in 'my_iterator'
typedef typename _Iterator::difference_type difference_type;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:129:35: error: no type
named 'pointer'
in 'my_iterator'
typedef typename _Iterator::pointer pointer;
~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/4.4/bits/stl_iterator_base_types.h:130:35: error: no type
named
'reference' in 'my_iterator'
typedef typename _Iterator::reference reference;
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
6 errors generated.
====================
It looks like it's throwing out the entire base class instead of instantiating
it with an error type for the _Reference parameter. This looks related to
PR5923, but is about using broken types instead of broken values.
--
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