c++/2494: Template Specialization Name Lookup

landry@physics.utah.edu landry@physics.utah.edu
Thu Apr 5 12:06:00 GMT 2001


>Number:         2494
>Category:       c++
>Synopsis:       Template Specialization Name Lookup
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 05 12:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Walter Landry
>Release:        gcc 2.95.2 and Codesourcery's nightly
>Organization:
>Environment:
Debian 2.2 (potato)
>Description:
gcc can't seem to generate the specialization in the example
code.  It gives the error

simple.C: In function `int main()':
simple.C:25: no match for call to `(Tensor1<double>) (Index<'i'> &)'

KCC version 3.4 and IBM's Visual Age C++ v5.0 both compile
without complaints, so I'm reasonably sure that this is
allowed by the language.

If I get rid of either of the template<>'s, i.e. change 

template <class T>
class Tensor1

to 

class Tensor1

or change

template<char i>
double operator()(Index<i> &index)

to

double operator()(Index<'i'> &index)

then it compiles fine.  But that doesn't give me the
functionality I need.
This may be a duplication of bugs 509, 72, and/or 45,
though they don't seem exactly the same.
>How-To-Repeat:
template<char i>
class Index
{
public:
  Index() {};
};

template <class T>
class Tensor1
{
public:
  template<char i>
  double operator()(Index<i> &index)
  {
    return 2.0;
  }
};

int main()
{
  Index<'i'> i;

  Tensor1<double> t1;

  t1(i);
}

To compile, it's just 

g++ simple.C
>Fix:
None known.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list