[Bug c++/53236] using declaration and base function template overloading
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Sun May 6 17:55:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53236
--- Comment #7 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-06 17:34:10 UTC ---
(In reply to comment #5)
> Here is a simplified code -> "gcc_error_simple.cpp"
> Shows two facets of the error.
>
> See the comments in the attached file.
Fixed and simplified that code we have:
//---
template<typename, typename, typename>
struct enable_same
{};
template<typename T, typename U>
struct enable_same<T, T, U>
{
typedef U type;
};
template <typename T>
struct Base
{
T u;
template <typename T2>
typename enable_same<T, T2, T>::type
get() { return u; }
};
template <typename T>
struct Derived : Base<int>
{
typedef Base<int> base;
#ifdef WITH_USING_DECLARATION
using base::get;
#endif
template <typename T2>
typename enable_same<T, T2, T>::type
get() { return this->u; } // Line 32
};
int main()
{
Derived<double> d;
d.get<double>();
d.get<int>(); // Line 39
}
//---
Using gcc 4.8.0 20120429 (experimental) I see different results (I see the same
thing with your unchanged code taking into account that a function returning
no-void is expected to be rejected):
a) #ifndef WITH_USING_DECLARATION: The code is accepted as it should.
b) #ifdef WITH_USING_DECLARATION: The code is rejected as it should:
In function 'int main()':|
39|error: no matching function for call to 'Derived<double>::get()'|
39|note: candidate is:|
32|note: template<class T2> typename enable_same<T, T2, T>::type Derived::get()
[with T2 = T2; T = double]|
|32|note: template argument deduction/substitution failed:|
39| required from here|
32|error: no type named 'type' in 'struct enable_same<double, int, double>'|
Even though the third line of the diagnostics is a bit misleading it is
certainly correct the function call, because the base class get template is
hidden without the using-declaration.
Summarizing, it seems that the variadic code is broken, not the non-variadic
case.
More information about the Gcc-bugs
mailing list