[Bug c++/19552] Compile error on template member function called from template function

andres_takach at mentorg dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 21 18:58:00 GMT 2005


------- Additional Comments From andres_takach at mentorg dot com  2005-01-21 18:58 -------
Subject: Re:  Compile error on template member function called
 from template function

Thanks for the workaround and for the fast response!

Looking at the standard this is what I see:

- mc_foo<W3> is a "dependent type" (14.6.2.1)
- val3.f<16> is a "type dependent expression" (14.6.2.2) since identifier val3 was defined with a "dependent type".
- Section 14.6.2 (last two sentences in paragraph 1) says:
    "If an operand of an operator is a type-depedent expression, the operator also denotes a dependent name. SUCH NAMES 
ARE UNBOUND AND ARE LOOKED UP AT THE POINT OF THE TEMPLATE INSTANTIATION (14.6.4.1) in both the context of the template 
definition and the context of the point of instantiation."

At the point of the template instantiation, the compiler does know that val3.f is a template. The code is therefore 
valid according to the C++ standard.

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-21 00:37 -------
> The code is invalid (by the C++ standard)
>   mc_foo<W3> val3 = val;    // W3 == 16 in this example
> val3.f<16>(0);
> 
> Since val3 is dependent name, we don't know that val3.f is a template so we reject the code.
> 
> you need to use the template keyword like so:
> val3.template f<16>(0);
> 
> 



-- 


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



More information about the Gcc-bugs mailing list