Y
Yevgen Muntyan
Hello all,
I have a piece of code which compiles with gcc-3.4 but not with intel compiler 8.1. If I correct
the code for intel compiler, then gcc refuses to compile it. The code is following:
////////////////////////////////// test.cpp
template <typename T>
void func ()
{
static T instance;
}
namespace blah {
class MyClass {
friend void func<MyClass> ();
MyClass () {} // private
};
}
int main ()
{
func<blah::MyClass>();
}
////////////////////////////// end of test.cpp
Error is in the 'friend void func<MyClass> ();' line. When I compile this file with
intel compiler, it says
test.cpp(4): error #373: "blah::MyClass::MyClass()" is inaccessible
static T instance;
^
detected during instantiation of "void func<T>() [with T=blah::MyClass]"
To make the compiler happy I change MyClass to
class MyClass {
friend void ::func<MyClass> (); // note the :: before func
MyClass () {}
};
But when g++ says
test2.cpp:11: error: `void func()' should have been declared inside `::'.
What's correct? I tried Comeau compiler on comeaucomputing.com, it compiles both
versions. Is this just two different bugs of g++ and intel compiler?
Thank you,
Yevgen
I have a piece of code which compiles with gcc-3.4 but not with intel compiler 8.1. If I correct
the code for intel compiler, then gcc refuses to compile it. The code is following:
////////////////////////////////// test.cpp
template <typename T>
void func ()
{
static T instance;
}
namespace blah {
class MyClass {
friend void func<MyClass> ();
MyClass () {} // private
};
}
int main ()
{
func<blah::MyClass>();
}
////////////////////////////// end of test.cpp
Error is in the 'friend void func<MyClass> ();' line. When I compile this file with
intel compiler, it says
test.cpp(4): error #373: "blah::MyClass::MyClass()" is inaccessible
static T instance;
^
detected during instantiation of "void func<T>() [with T=blah::MyClass]"
To make the compiler happy I change MyClass to
class MyClass {
friend void ::func<MyClass> (); // note the :: before func
MyClass () {}
};
But when g++ says
test2.cpp:11: error: `void func()' should have been declared inside `::'.
What's correct? I tried Comeau compiler on comeaucomputing.com, it compiles both
versions. Is this just two different bugs of g++ and intel compiler?
Thank you,
Yevgen