This is the mail archive of the 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: [Darwin] Patch c++/15428

On Thu, 20 May 2004 14:00:32 -0700, Matt Austern <> wrote:

> On May 20, 2004, at 11:57 AM, Jason Merrill wrote:
>> On Thu, 20 May 2004 11:38:11 -0700, Matt Austern <>
>> wrote:
>>>>>        explicitly_instantiate_members =
>>>>>          && previous_instantiation_extern_p && ! extern_p
>>>>>          && ! TYPE_FOR_JAVA (t);
>>> OK, so here' s a specific code example.  Suppose we have a header file
>>> x.h
>>> with the following declarations:
>>>    template <typename T> struct X { void foo(); };
>>>    template <typename T> void X<T>::foo() { };
>>>    extern template struct X<int>;
>>> Now we include that header file into two source files, and  In
>>> we use X<int>::foo(), but we don't have an explicit instantiation.
>>> In we do have an explicit instantiation.  a.o will have an
>>> unresolved reference to _ZN1XIiE3fooEv, which is expected to be defined
>>> elsewhere.  b.o will have a definition.  The point is that we need to
>>> make sure that the definition of _ZN1XIiE3fooEv in b.o isn't weak.  So we
>>> do two things.  First, we do explicit instantiations, not implicit, for
>>> member functions of explicitly instantiated class templates.
>> My issue is twofold:
>> 1) It seems to me that the above code would accomplish this for your
>> testcase without checking TARGET_WEAK_IN_ARCHIVE_TOC; since the previous
>> instantiation was "extern", this one will be explicit.
> I believe the check for the macro is necessary.  We know that the
> instantiation of this class template is explicit, but we still have to
> decide whether that means that the members should be instantiated
> explicitly or implicitly.


> On most targets we deliberately decided to do the latter.


> On Darwin we need to do the former.

I still don't see why.  You explained above why this is necessary if
there's a previous extern instantiation, but in that case we already do
explicit instantiations on all targets.


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