This is the mail archive of the gcc-bugs@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]

[Bug c++/49198] New: GCC trunk and 4.6 generate spurious "has incomplete type" errors


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.


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