Hi,

I haven't found any related bug in the known bugs database.
Also I posted this problem to several forums to be shore that this code doesn't
violate the C++ standard. ~60% replies that this should work. Moreover two
other compilers can compile without any problem:

The simplified code:
//////////////////////////////////
#include <stdio.h>
template <typename T, int v> class record_descriptor {
public:
     void operator()()
     {
         printf("Global template\n");
     }
};
template<typename T, int v, template<typename,int> class RD =
record_descriptor> class TableRecord {
public:
     TableRecord()
     {
         RD<T, v> d;
         d();
     }
};
template<typename A> class Attr
{
public:
     template <typename T, int v> class i_record_descriptor
     {
     };
     template <int v> class i_record_descriptor<A, v>
     {
     public:
         void operator()()
         {
             printf("Inner spec template\n");
         }
     };
     Attr()
     {
         TableRecord<A, 1, i_record_descriptor> tr;
     }
};
int main()
{
     Attr<int> attr;
     return 0;
}
//////////////////////////////
Message:
gccbug.cpp: In constructor 'TableRecord<T, v, RD>::TableRecord() [with T = int,
int v = 1, RD = Attr<int>::i_record_descriptor]':
gccbug.cpp:32:   instantiated from 'Attr<A>::Attr() [with A = int]'
gccbug.cpp:37:   instantiated from here
gccbug.cpp:15: error: no match for call to
'(Attr<int>::i_record_descriptor<int, 1>) ()'
--------------------------------------------------------
If i_class_descriptor template has an implementation:
//////////////////////////////////////////////////////
#include <stdio.h>
template <typename T, int v> class record_descriptor {
public:
     void operator()()
     {
         printf("Global template\n");
     }
};
template<typename T, int v, template<typename,int> class RD =
record_descriptor> class TableRecord {
public:
     TableRecord()
     {
         RD<T, v> d;
         d();
     }
};
template<typename A> class Attr
{
public:
     template <typename T, int v> class i_record_descriptor
     {
     public:
         void operator()()
         {
             printf("Inner template\n");
         }
     };
     template <int v> class i_record_descriptor<A, v>
     {
     public:
         void operator()()
         {
             printf("Inner spec template\n");
         }
     };
     Attr()
     {
         TableRecord<A, 1, i_record_descriptor> tr;
     }
};
int main()
{
     Attr<int> attr;
     return 0;
}
/////////////////////////////////////////////////////
...compiles but the result after executing is "Inner template" instead of
"Inner spec template"

If the parameter 'A' is changed in the partial specialozation to a primitve
type, ex: 'int' then compiles fine and the result is correct.

The last version I tried was:
g++ (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)

I hope I give you all the necessary information!

Regards,
Zoltan Jasz

Software developer,
Ericsson Telecomunication Hungary Ltd.


-- 
           Summary: Name lookup bug for inner template specialization
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zjasz at yahoo dot com
 GCC build triplet: 4.1.1 20060525 (Red Hat 4.1.1-1)
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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

Reply via email to