对于LynxOS-178B 2.2.2,我面临着一个g ++版本(2.9-gnupro-98r2)的编译错误,而相同的代码将被编译而不会抱怨更新版本的g ++,例如: 4.3.3 for VxWorks 653 2.4.0.2。
以下示例说明了问题:
int function_1(int)
{
return 4;
}
double function_2(double)
{
return 2;
}
typedef int (*fp1)(int);
typedef double (*fp2)(double);
struct A
{
operator fp1()
{
return function_1; // conversion function to pointer to function
}
operator fp2()
{
return function_2; // conversion function to pointer to function
}
}a;
int call_to_class_object_1()
{
double i = a(3.6); // calls function_2 via pointer returned from conversion function
return i;
}
int call_to_class_object_2()
{
int i = a(6); // calls function_1 via pointer returned from conversion function
return i;
}
我在哪里调用双i = a(3.6);和int i = a(6);我收到错误
对于2.9-gnupro-98r2,我得到了:
../../src/Overloading_13_3_1_1_2_Call_to_object_of_class_type.cpp(30) : error: Internal compiler error.
../../src/Overloading_13_3_1_1_2_Call_to_object_of_class_type.cpp(30) : error: Please submit a Problem Report to Lynx Technical Support (support@lynx.com).
make[1]: *** [Overloading_13_3_1_1_2_Call_to_object_of_class_type.o] Error 1
如果一个编译器版本接受代码,则不能完全错误。我的猜测是它符合C ++标准,但较旧的编译器缺乏适当的实现。