This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/33605] New: Comparable concepts cause errors with abstract types
- From: "gcc at david dot osborn dot name" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Sep 2007 22:42:16 -0000
- Subject: [Bug libstdc++/33605] New: Comparable concepts cause errors with abstract types
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code fails because __gnu_cxx::_LessThanOpConcept has member
variables of type <iterator>::value_type, where <iterator> is an iterator over
an abstract type. 20.1.2 (LessThanComparable) doesn't mention that the type
has to be concrete.
#define _GLIBCXX_CONCEPT_CHECKS
#include <algorithm>
#include <tr1/memory>
#include <vector>
#include <boost/iterator/indirect_iterator.hpp>
struct AbstractThing
{
virtual void F() = 0; // comment this out and it works
};
struct ConcreteThing : AbstractThing
{
void F() {}
};
bool operator <(const AbstractThing &, const AbstractThing &)
{
return false;
}
int main()
{
typedef std::vector<std::tr1::shared_ptr<AbstractThing> > Things;
Things things;
std::lower_bound(
boost::make_indirect_iterator(things.begin()),
boost::make_indirect_iterator(things.end()), ConcreteThing());
}
$ g++ -I../../../boost.1.34.0 -otest test.cpp
C:/devel/mingw/include/c++/4.2.1/bits/boost_concept_check.h: In instantiation
of
'__gnu_cxx::_LessThanOpConcept<AbstractThing, ConcreteThing>':
C:/devel/mingw/include/c++/4.2.1/bits/boost_concept_check.h:63: instantiated
f
rom 'void __gnu_cxx::__function_requires() [with _Concept =
__gnu_cxx::_LessThan
OpConcept<AbstractThing, ConcreteThing>]'
C:/devel/mingw/include/c++/4.2.1/bits/stl_algo.h:2894: instantiated from
'_For
wardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)
[w
ith _ForwardIterator =
boost::indirect_iterator<__gnu_cxx::__normal_iterator<std
::tr1::shared_ptr<AbstractThing>*,
std::vector<std::tr1::shared_ptr<AbstractThin
g>, std::allocator<std::tr1::shared_ptr<AbstractThing> > > >,
boost::use_default
, boost::use_default, boost::use_default, boost::use_default>, _Tp =
ConcreteThi
ng]'
test.cpp:26: instantiated from here
C:/devel/mingw/include/c++/4.2.1/bits/boost_concept_check.h:299: error: cannot
d
eclare field '__gnu_cxx::_LessThanOpConcept<AbstractThing, ConcreteThing>::__a'
to be of abstract type 'AbstractThing'
test.cpp:8: note: because the following virtual functions are pure within
'Abs
tractThing':
test.cpp:9: note: virtual void AbstractThing::F()
--
Summary: Comparable concepts cause errors with abstract types
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at david dot osborn dot name
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33605