Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tr1987
Beginner
101 Views

Combining the 'using' directive with partial overloading: gcc feature or intel bug?

I wish to use a set of libraries written in C++ with the Intel compilers. I've attached sample code which demonstrates the problem. There are many places in the libraries where they make use of combining the 'using' directive with partial overloading (e.g., I want to use the foo(void) method from the base class but reimplement the second version fo foo in the derived class). gcc does not have a problem but intel does.
[cpp]#include 
template 
struct Interface
{
 static const F f=10;
};
template 
struct Base : public Interface
{
 void foo (void) { std::cout << "void" << std::endl; }
 template 
 void foo (Interface &ii) { std::cout << "F : " << ii.f << std::endl; }
};

template 
struct Derived : public Base
{
 // void foo (void) { Base::foo(); }  // works fine
 using Base::foo;                     // gives error
 template 
 void foo (Interface &ii) { std::cout << "Derived<" << i << "> F : " << ii.f << std::endl; }
};

int main (void)
{
 Derived o;
 o.foo();                  // ok
 o.foo (o);                // problem
}[/cpp]
The compiler error that icc gives is:
[bash]test.cc(30): error: more than one instance of overloaded function "Derived::foo    [with F=double, i=10]" matches the argument list:
        function template "void Base::foo(Interface &) [with F=double]"
        function template "void Derived::foo(Interface &) [with F=double, i=10]"
        argument types are: (Derived)
        object type is: Derived
o.foo (o);                // problem
  ^

compilation aborted for test.cc (code 2)[/bash]

If you remove the line

[cpp] using Base::foo;[/cpp]

and replace it with the line

[bash] void foo (void) { Base::foo(); }[/bash]

everything works fine.

My question is does anyone know if this is a special gcc feature or icc bug? Or is there another work around which would not involve changing the code?

This is with g++.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3 and icc (ICC) 12.0.2 20110112.

0 Kudos
3 Replies
Judith_W_Intel
Employee
101 Views


This is fixed in version 12.1.
tr1987
Beginner
101 Views

Thanks for the information. This does fix my problem.
I would now like to convince others that upgrading to version 12.1 is important too, can you tell me if there is a specific bug report (or similar) that refers to this?
Reply