From mboxrd@z Thu Jan 1 00:00:00 1970 From: sts@ica1.uni-stuttgart.de To: gcc-gnats@gcc.gnu.org Subject: c++/3614: failing overloading of template member functions in template classes Date: Mon, 09 Jul 2001 02:56:00 -0000 Message-id: <20010709095105.511.qmail@sourceware.cygnus.com> X-SW-Source: 2001-07/msg00212.html List-Id: >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::f()' // class_tmpl_ovld.cc:25: `int A::f()' previously declared here // class_tmpl_ovld.cc:28: expected 2 levels of template parms for `int A::f() ', // got 1 // class_tmpl_ovld.cc:20: confused by earlier errors, bailing out template struct A { int f(); template int f(); }; template template int A::f(){ return M; } template int A::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: