This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49198] New: GCC trunk and 4.6 generate spurious "has incomplete type" errors
- From: "aaw at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 May 2011 18:40:17 +0000
- Subject: [Bug c++/49198] New: GCC trunk and 4.6 generate spurious "has incomplete type" errors
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49198
Summary: GCC trunk and 4.6 generate spurious "has incomplete
type" errors
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: aaw@gcc.gnu.org
Created attachment 24376
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24376
Minimal reproduction
See the attached tst.cc file. When compiled with GCC trunk and 4.6, it
generates the following errors:
tst.cc: In instantiation of âS<IC>â:
tst.cc:14:7: instantiated from here
tst.cc:3:32: error: âS<T>::tâ has incomplete type
tst.cc:1:7: error: forward declaration of âstruct ICâ
However, the code is structured such that IC need not be complete. According
to the C++ standard (14.7.1):
"Unless a class template specialization has been explicitly instantiated
(14.7.2) or explicitly specialized (14.7.3), the class template specialization
is implicitly instantiated when the specialization is referenced in a context
that requires a completely-defined object type or when the completeness of the
class type affects the semantics of the program."
In this case, we only refer to S<IC>* (pointer), which does not require a
complete type. Therefore, the class template specialization S<IC> should not
be instantiated, and IC need not be complete.
Various trivial modifications to this program (e.g. replacing S<IC>* with IC*
or replacing FT(F) with F) do not generate an error. Nor does GCC 4.4.3.