This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
template bug
- To: gcc at gcc dot gnu dot org
- Subject: template bug
- From: "Florin Iucha" <florin at iucha dot net>
- Date: Sun, 6 May 2001 12:12:41 -0500 (CDT)
Hello!
I think I've found a bug in the g++ compiler.
I am trying to compile this code:
---cut here---
template <int SIZE>
class B
{
public:
class P
{
public:
P(int x) : x_(x) {}
int x() const { return x_; }
private:
int x_;
};
P get_a_P() { return P(SIZE/2); }
};
class G : private B<10>
{
public:
void test();
};
template<int SIZE>
B<SIZE>::P the_bug(B<SIZE>::P p)
{
// do nothing
return p;
}
void G::test()
{
P p = get_a_P();
P q = the_bug(p);
}
int main()
{
G g;
g.test();
return 0;
}
---cut-here---
and I get this error:
templbug.cpp: In member function `void G::test()':
templbug.cpp:42: no matching function for call to `the_bug(B<10>::P&)'
I have checked with g++-snapshot-20010503 and RH g++ 2.96-81
If I remove the template specifier from the_bug and define SIZE to be 10,
the code compiles. If I define SIZE to something other than 10, the code
fails as expected.
Thanks for your good work!
florin