C++ using declaration for a template method
Paolo Calafiura
pcalafiura@lbl.gov
Fri Aug 10 15:50:00 GMT 2001
Hi guys,
the following does not compile - as I believe it should - using gcc 3.0 or even
the head of 3.1
#include <iostream>
using namespace std;
class Base {
public:
template <typename Foo>
void useFoo(Foo foo) {cout << "useFoo prints " << foo << endl;}//line #6
void useInt(int i) {cout << "useInt prints " << i << endl;}
};
class Derived: private Base {
public:
using Base::useInt;
using Base::useFoo;
};
int main() {
Derived d;
int i(1);
d.useInt(i);
d.useFoo(i); //line #22
return 0;
}
GCC Output:
[test]$ uname -a
Linux ------- 2.4.7-ac1 #37 Sat Aug 4 10:32:54 PDT 2001 i686 unknown
[test]$ g++ -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcchead/configure --enable-languages=c++,f77,java
Thread model: single
gcc version 3.1 20010810 (experimental)
[test]$ g++ using.cxx
using.cxx: In function `int main()':
using.cxx:6: `void Base::useFoo(Foo) [with Foo = int]' is inaccessible
using.cxx:22: within this context
I have found a similar bug report
http://gcc.gnu.org/ml/gcc-bugs/2001-08/msg00146.html
posted few days ago and a later message msg00178.html saying it has been
fixed in 3.1 sources.
Paolo
FIY with KCC 4.0 the code above compiles and runs as I expected...
More information about the Gcc-bugs
mailing list