[Bug c++/22621] [3.4/4.0/4.1 Regression] Member function overloading introduces syntax errors

squell at alumina dot nl gcc-bugzilla@gcc.gnu.org
Sat Jul 23 02:03:00 GMT 2005


------- Additional Comments From squell at alumina dot nl  2005-07-23 01:59 -------
When I changed the function body by removing all "foo::"
qualifiers, I got the following;

int foo::f()
{
   f_obj<&f> a;  // ERROR: missing '>' in template argument list
   f_obj<f>  b;  // ERROR: foo::f in constant expression

   f_obj<&g> c;  // OK
   f_obj<g>  d;  // OK
}

gcc 3.3 also gave an error on those two lines, complaining that 
"&this->foo::f" is not a valid template argument. I can't find
why it says so - it's a constant expression and it should overload
resolve it.

However, g++ _is_ correct in transforming 'f' to "this->foo::f" in the
first case to "foo::g" in the second (with or without explicit "foo::").

So I think this test-case can be reduced to (fails on 3.4 and 4.0):

struct foo {
    static int f();
} *ptr;

template<int fun()> struct bar { };

bar< ptr->f > a;  // ERROR: `->' cannot appear in constant expression
bar< &ptr->f > b; // ERROR: '>' missing in template argument



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22621



More information about the Gcc-bugs mailing list