Bug 37657 - static template member definition fails when parameter is another template
Summary: static template member definition fails when parameter is another template
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-27 04:45 UTC by Roberto Jacob Da Silva
Modified: 2011-09-25 21:54 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Jacob Da Silva 2008-09-27 04:45:54 UTC
+++ This bug was initially created as a clone of Bug #14132 +++

Hello,

 I would like to start from the final solution presented for Bug # 14132 copied below for reference:

So when the old code looks like:
| 
|   int A<void>::a;
| 
| it must be replaced by:
| 
|   template class A<void>;
|   template<class T> int A<T>::a;

Reverse the order:

   (1) provide the template definition of the static data member
   (2) instantiate the class.

In our case, this type of construct works as described for the case where the parameter for the template member definition is a class, structure or native type. For instance:

The following code was building and running fine in GCC 3.3 on Power PC.

pool_t memdat_t<mem_t, small>::pool;

Using the technique depicted in this bug, I have converted that into the code below:

template class  memdat_t<mem_t, small>;
template<class T, unsigned int U> pool_t memdat_t<T, U>::pool;

This code builds and runs on both GCC 3.3 (PPC) and GCC 3.4 (ARM).

If I now have a code that is a little bit more complicated, like the one below, things get tough.

pool_t memdat_t<addr_type_t<ipv4_addr_t>, huge>::pool;
pool_t memdat_t<addr_type_t<ipv6_addr_t>, huge>::pool;

I need to define two static members that will be differentiated based on the address family (IPv4 or IPv6).

The issue is that one of the parameters of the static template member is another template (addr_type_t<ipv4_addr_t> or addr_type_t).

I have not been able to figure out a way to write this code in such a way that it works (compiles and links correctly) for both GCC 3.3 and 3.4. 


Thanks in Advance,
rds
Comment 1 Paolo Carlini 2011-09-25 21:54:54 UTC
Not a PR.