- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]#includetemplate 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.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is fixed in version 12.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page