* Re: Using incomplete types to instantiate STL-Templates?
@ 2003-04-30 17:19 Wolfgang Bangerth
2003-04-30 18:28 ` Gabriel Dos Reis
2003-05-01 2:04 ` Fergus Henderson
0 siblings, 2 replies; 6+ messages in thread
From: Wolfgang Bangerth @ 2003-04-30 17:19 UTC (permalink / raw)
To: gcc, gdr, Christian Ehrhardt
Note that libstdc++ _does_ actually accept the code Christian showed. It
only rejects it if concepts checking is on. I think that's weird, and
personally consider it a defect in the way the concepts checks are
implemented.
In this case, the concepts checks are placed at class declaration level,
which is too early. Since std::list only stores pointers to objects, the
class pointed to needs not be complete at this time. It would be
sufficient to place the concepts check into one of the member functions,
by which the requirement of completeness of _Tp would be deferred.
However, that's just a layman's opinion :-)
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using incomplete types to instantiate STL-Templates?
2003-04-30 17:19 Using incomplete types to instantiate STL-Templates? Wolfgang Bangerth
@ 2003-04-30 18:28 ` Gabriel Dos Reis
2003-04-30 23:34 ` Wolfgang Bangerth
2003-05-01 2:04 ` Fergus Henderson
1 sibling, 1 reply; 6+ messages in thread
From: Gabriel Dos Reis @ 2003-04-30 18:28 UTC (permalink / raw)
To: Wolfgang Bangerth; +Cc: gcc, Christian Ehrhardt
Wolfgang Bangerth <bangerth@ices.utexas.edu> writes:
| Note that libstdc++ _does_ actually accept the code Christian showed. It
| only rejects it if concepts checking is on.
Yes, that is what I was referring to when I said that accepting the
code puts severe restrictings on the implementations.
I don't think there is much we can do about it -- we all know the code
is violating a specific clause, e.g. constructing a list of incomplete
type.
| I think that's weird, and
| personally consider it a defect in the way the concepts checks are
| implemented.
STL concepts checking in pure C++ is a tough task. I would be pleased to
read your implementations :-)
[ I do know for sure that como + libcomo and concept checking does
reject some well-formed programs ]
-- Gaby
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using incomplete types to instantiate STL-Templates?
2003-04-30 18:28 ` Gabriel Dos Reis
@ 2003-04-30 23:34 ` Wolfgang Bangerth
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Bangerth @ 2003-04-30 23:34 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: gcc, Christian Ehrhardt
> | I think that's weird, and
> | personally consider it a defect in the way the concepts checks are
> | implemented.
>
> STL concepts checking in pure C++ is a tough task. I would be pleased to
> read your implementations :-)
Fair enough. I didn't imply any blame in my wording -- heck, all my job in
gcc is pointing out errors in some part of gcc or other ;-) If I had to
fix them all, I'd have a problem...
What I thought is that deferring concepts check to the time we actually
instantiate an object might be done by placing the check machinery into
the constructors, since that's the first place we end up in anyway.
[Thinks] Actually, that's not true -- you might just be passed a pointer
and call member functions from there. So one would have to duplicate
concepts checks in _all_ member functions. Nope, I don't think we want to
do that.
I think I now see what you mean :-) That being said, I still think it's a
defect, even though it may be impossible to fix it.
Time for constraints on template parameters...
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using incomplete types to instantiate STL-Templates?
2003-04-30 17:19 Using incomplete types to instantiate STL-Templates? Wolfgang Bangerth
2003-04-30 18:28 ` Gabriel Dos Reis
@ 2003-05-01 2:04 ` Fergus Henderson
1 sibling, 0 replies; 6+ messages in thread
From: Fergus Henderson @ 2003-05-01 2:04 UTC (permalink / raw)
To: Wolfgang Bangerth; +Cc: gcc, gdr, Christian Ehrhardt
On 30-Apr-2003, Wolfgang Bangerth <bangerth@ices.utexas.edu> wrote:
>
> Note that libstdc++ _does_ actually accept the code Christian showed. It
> only rejects it if concepts checking is on. I think that's weird, and
> personally consider it a defect in the way the concepts checks are
> implemented.
The point of concept checking is to check that the class used to
instantiated a template meets (the checkable subset of) the standard's
requirements. One of the requirements that the standard imposes is that
the class must be complete. So it is surely right for the concept checking
to reject such classes!
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using incomplete types to instantiate STL-Templates?
2003-04-30 16:49 Christian Ehrhardt
@ 2003-04-30 16:49 ` Gabriel Dos Reis
0 siblings, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2003-04-30 16:49 UTC (permalink / raw)
To: Christian Ehrhardt; +Cc: gcc
"Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> writes:
[...]
| * For the standard library there is this restriction in 17.3.4.6[2]:
|
| In particular, the effects are undefined in the following cases:
| [ ... ]
| -- if an incomplete type (3.9) is used as a template argument
| when instantiating a template component.
|
| I'm not sure if the second point is really relevant. Mostly because
| I'm not entirely sure what a template component is supposed to be.
The text you cited is relevant: The component in question in this
particular configuration is std::list<>.
This is the kind of thing that really depends on implementation details.
It would be nice if Foo were accepted but that do put severe
restrictions on the implementation.
-- Gaby
^ permalink raw reply [flat|nested] 6+ messages in thread
* Using incomplete types to instantiate STL-Templates?
@ 2003-04-30 16:49 Christian Ehrhardt
2003-04-30 16:49 ` Gabriel Dos Reis
0 siblings, 1 reply; 6+ messages in thread
From: Christian Ehrhardt @ 2003-04-30 16:49 UTC (permalink / raw)
To: gcc
Hi,
the following piece of code fails with --enable-concept-checks
(this is PR 10505):
------- cut ----------
#include <list>
class Foo
{
public:
int x;
std::list<Foo> children;
};
------- cut ----------
This happens because instantiation of std::list<Foo> will try to
declare a variable of type Foo. This fails because Foo is incomplete
at the point of instantiation. Basically the question is:
Is this construct legal?
I could only find two things that might be relevant to this in the
standard:
* Generally it is allowed to instatiate a template with an incomplete type.
However, the program may be ill-formed depending on what the template does
with this incomplete type (I can dig up the section numbers if this is
necessary).
* For the standard library there is this restriction in 17.3.4.6[2]:
In particular, the effects are undefined in the following cases:
[ ... ]
-- if an incomplete type (3.9) is used as a template argument
when instantiating a template component.
I'm not sure if the second point is really relevant. Mostly because
I'm not entirely sure what a template component is supposed to be.
regards Christian
--
THAT'S ALL FOLKS!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-05-01 2:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-30 17:19 Using incomplete types to instantiate STL-Templates? Wolfgang Bangerth
2003-04-30 18:28 ` Gabriel Dos Reis
2003-04-30 23:34 ` Wolfgang Bangerth
2003-05-01 2:04 ` Fergus Henderson
-- strict thread matches above, loose matches on Subject: below --
2003-04-30 16:49 Christian Ehrhardt
2003-04-30 16:49 ` Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).