public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* (undocumented?) difference between gcc 4.6 and 4.7 (C++ implicit template instantiation)
@ 2012-08-28 17:24 Christoph Groth
  2012-08-28 17:29 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Groth @ 2012-08-28 17:24 UTC (permalink / raw)
  To: gcc-help

Dear GCC experts,

While developing a Python extension using CPython's C API in C++ I've
encountered a situation where a program compiles with GCC 4.7.1 but does
not compile with 4.6.3.  I have attached a minimal program demonstrating
the problem.  As a workaround, adding a explicit instantiation makes the
program also compile under GCC 4.6.

I've been unable to find a description of this issue in any changelog.
Actually, I wonder whether the behavior of 4.6 or that of 4.7 is the
correct one with regard to the C++ language standard.

Is this a known issue which has been fixed in 4.7, or rather a
regression from 4.6?



// Compile with: g++ test.cc

typedef void *(*Func)(void *);

template <typename T>
class Class {
public:
    static Func hoho;
};

template <typename T>
void *something(Class<T> *self)
{
}

// The following line makes it compile under GCC 4.6
// template void *something(Class<long>*);

template <typename T>
Func Class<T>::hoho = (Func)something<T>;

// Explicit instantiation.  This does instantiate something<long>
// under GCC 4.7 but not under GCC 4.6.
template class Class<long>;

int main()
{
    Class<long>::hoho(0);
}

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

end of thread, other threads:[~2012-08-28 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-28 17:24 (undocumented?) difference between gcc 4.6 and 4.7 (C++ implicit template instantiation) Christoph Groth
2012-08-28 17:29 ` Jonathan Wakely
2012-08-28 20:32   ` Christoph Groth

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).