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++/37657] New: static template member definition fails when parameter is another template


+++ 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


-- 
           Summary: static template member definition fails when parameter
                    is another template
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: robertohjdasilva at hotmail dot com


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


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