Y
ymost
Hi,
I have a code that generates: "internal compiler error: Segmentation
fault" while compiling with gcc-4 (both on linux and on windows).
Here it is:
//--------------------------------------------------------------------
template< typename T,typename T2 > T addw(T x,T2 y) {return x+(T)y;};
template< typename T > struct A {
template< typename T2,T (* const operation)(T,T2) > struct B {};
template< typename T2 > friend const B< T2,addw<T,T2> > func(T x, T2
y) {return B< T2,addw<T,T2> >();};
};
int main() {
A<double> a,b;
func(1.2,1.3); // <-- Segmentation fault received here
return 0;
}
//--------------------------------------------------------------------
Can anyone tell if there is a problem with this code, or is this just
a compiler bug?
The only special "feature" I can see here is using a function pointer
as a template argument, but under different circumstances it works
fine...
I have a code that generates: "internal compiler error: Segmentation
fault" while compiling with gcc-4 (both on linux and on windows).
Here it is:
//--------------------------------------------------------------------
template< typename T,typename T2 > T addw(T x,T2 y) {return x+(T)y;};
template< typename T > struct A {
template< typename T2,T (* const operation)(T,T2) > struct B {};
template< typename T2 > friend const B< T2,addw<T,T2> > func(T x, T2
y) {return B< T2,addw<T,T2> >();};
};
int main() {
A<double> a,b;
func(1.2,1.3); // <-- Segmentation fault received here
return 0;
}
//--------------------------------------------------------------------
Can anyone tell if there is a problem with this code, or is this just
a compiler bug?
The only special "feature" I can see here is using a function pointer
as a template argument, but under different circumstances it works
fine...