public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37256]  New: extern template / explicit instantiation broken in 4.4.0-pre
@ 2008-08-27 14:45 ciaran dot mccreesh at googlemail dot com
  2008-08-27 16:35 ` [Bug c++/37256] " paolo dot carlini at oracle dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ciaran dot mccreesh at googlemail dot com @ 2008-08-27 14:45 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1478 bytes --]

The following C++ code compiles (but doesn't link) with g++ 4.3.1:

    template <typename T_>
    struct B
    {
        T_ f();
    };

    extern template class B<int>;

    void f()
    {
        B<int> t;
        t.f();
    }

With 'gcc () 4.4.0-pre9999 built 20080827 (Gentoo SVN ebuild) rev. 139623', the
following error occurs:

$ g++ -O1 a.cc 
a.cc: In instantiation of ‘T_ B<T_>::f() [with T_ = int]’:
a.cc:12:   instantiated from here
a.cc:12: error: explicit instantiation of ‘T_ B<T_>::f() [with T_ = int]’ but
no definition available

If no -O is specified, the error does not occur. Using -std=c++0x does not
alter the outcome.

I'm looking at n2723 14.7.2 for what the behaviour should be. My understanding
is as follows: By paragraph 7, the explicit instantiation declaration for
B<int> is also an explicit instantiation declaration for int B<int>::f(). Thus,
by paragraph 3, a definition of B<int> must be available when declaring int
B<int>::f(), which it is. But I don't see a requirement for a definition of
B<int>::f().


-- 
           Summary: extern template / explicit instantiation broken in
                    4.4.0-pre
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ciaran dot mccreesh at googlemail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37256


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-11-19 19:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 14:45 [Bug c++/37256] New: extern template / explicit instantiation broken in 4.4.0-pre ciaran dot mccreesh at googlemail dot com
2008-08-27 16:35 ` [Bug c++/37256] " paolo dot carlini at oracle dot com
2008-08-27 16:50 ` sebor at roguewave dot com
2008-08-27 16:54 ` paolo dot carlini at oracle dot com
2008-08-27 17:09 ` ciaran dot mccreesh at googlemail dot com
2008-08-27 17:18 ` paolo dot carlini at oracle dot com
2008-08-27 19:37 ` [Bug c++/37256] [4.4 Regression] " paolo dot carlini at oracle dot com
2008-08-27 19:39 ` pinskia at gcc dot gnu dot org
2008-09-09 20:26 ` jsm28 at gcc dot gnu dot org
2008-11-19  0:11 ` jason at gcc dot gnu dot org
2008-11-19 19:30 ` jason at gcc dot gnu dot org
2008-11-19 19:42 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).