This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Templates with incomplete types
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: austern at apple dot com (Matt Austern)
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 8 Jul 2004 15:40:21 -0400 (EDT)
- Subject: Re: Templates with incomplete types
>
> Consider the following test case:
> struct abc;
>
> template <typename T>
> void foo(T, abc* p)
> {
> p->do_it();
> }
>
> struct abc { void do_it(); };
>
> void invoker()
> {
> abc tmp;
> foo(17, &tmp);
> }
>
> On the other hand, in 3.3 we used to accept this code, and I suspect a
> number of other compilers did too. (That's what'll happen if you do
> all name lookup at the point of instantiation.) I suspect there's
> still code out there that relies on the old behavior. Should we
> provide a switch that'll get the old behavior back?
ICC 6.0 in non-strict mode accepts this but when in strict mode: -Xc -ansi,
it rejects it with the following error message:
t.cc
t.cc(6): error: pointer to incomplete class type is not allowed
p->do_it();
^
compilation aborted for t.cc (code 2)
Thanks,
Andrew Pinski