This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]