c++/3614: failing overloading of template member functions in template classes

sts@ica1.uni-stuttgart.de sts@ica1.uni-stuttgart.de
Mon Jul 9 02:56:00 GMT 2001


>Number:         3614
>Category:       c++
>Synopsis:       failing overloading of template member functions in template classes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 09 02:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     sts@ica1.uni-stuttgart.de
>Release:        gcc-3.0
>Organization:
>Environment:
alpha OSF 5.0, ix86-linux
>Description:
// I cannot see a problem with the syntax of the following 
// fragment; shouldn't one be able to overload template and 
// non-template functions in class scopes and be able to declare 
// them out of line?  From the examples in Sec. 14 of the standard
// my guess is that the fragment below uses the syntax intended for 
// this purpose. EDG compilers treat this fragment as I expect (the 
// executable returns 0 to the environent)

// the _inline_ definition of the functions IN the class 
// body works as expected

// Stefan Schwarzer sts@ica1.uni-stuttgart.de

// 11:30 tiger_sts:gnu/current> g++ -v
// Reading specs from /local/gcc-3.0/lib/gcc-lib/alphaev56-dec-osf4.0f/3.0/specs
// Configured with: /share/src/gcc-3.0/configure --prefix=/local/gcc-3.0 --host=
alphaev56-dec-osf4.0f --target=alphaev56-dec-osf4.0f
// Thread model: single
// gcc version 3.0

// 11:30 tiger_sts:gnu/current> g++ class_tmpl_ovld.cc
// class_tmpl_ovld.cc:28: redefinition of `int A<N>::f()'
// class_tmpl_ovld.cc:25: `int A<N>::f()' previously declared here
// class_tmpl_ovld.cc:28: expected 2 levels of template parms for `int A<N>::f()
', 
//   got 1
// class_tmpl_ovld.cc:20: confused by earlier errors, bailing out



template<int N>
struct A {

  int f();  

  template<int M>
  int f();

};

template<int N> template<int M>
int A<N>::f(){ return M; } 

template<int N>
int A<N>::f(){ return 1; }

// should compile and return 0
int main(){
  A<42> a;
  return a.f<0>();
}
>How-To-Repeat:
see problem description
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list