This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/10505: concepts checks fail if container of X is used as member variable of X
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, tjj at aol dot net
- Date: 28 Apr 2003 18:50:27 -0000
- Subject: Re: libstdc++/10505: concepts checks fail if container of X is used as member variable of X
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, tjj at aol dot net, gcc-gnats at gcc dot gnu dot org
Old Synopsis: [sparc only] g++ 3.2.1 on sun won't compile obj with list ofobj as member data
New Synopsis: concepts checks fail if container of X is used as member variable of X
State-Changed-From-To: feedback->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Apr 28 18:50:27 2003
State-Changed-Why:
This is actually a problem in libstdc++. If one switched on
concepts checking, the following fails:
----------------------------
#include <list>
class Foo {
std::list<Foo> children;
};
------------------------------
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -c x.cc -D _GLIBCPP_CONCEPT_CHECKS
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/boost_concept_check.h: In instantiation of `__gnu_cxx::_SGIAssignableConcept<Foo>':
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/stl_list.h:369: instantiated from `std::list<Foo, std::allocator<Foo> >'
x.cc:4: instantiated from here
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/boost_concept_check.h:184: error: `
__gnu_cxx::_SGIAssignableConcept<_Tp>::__a' has incomplete type
x.cc:3: error: forward declaration of `class Foo'
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/boost_concept_check.h: In
member function `void __gnu_cxx::_SGIAssignableConcept<_Tp>::__constraints()
[with _Tp = Foo]':
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/stl_list.h:369: instantiated from `std::list<Foo, std::allocator<Foo> >'
x.cc:4: instantiated from here
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/boost_concept_check.h:176: error: `
__a' undeclared (first use this function)
/home/bangerth/bin/gcc-3.4-pre/include/c++/3.4/bits/boost_concept_check.h:176: error: (Each
undeclared identifier is reported only once for each function it appears
in.)
It fails, since the concepts checks try to check for assignability,
but at a time when class X is not yet complete.
I think, this is a defect in the library, although one that
is hard to work around. One possibility would be to move
the concept checks from the class declaration to the
body of the constructor -- at this time the class being
used _must_ be complete. However, I'd better leave this to
the experts in the field...
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10505