This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
is it a bug?
- From: Patrick Lacasse <patrick dot lacasse at genome dot ulaval dot ca>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 8 Nov 2007 08:40:33 -0500
- Subject: is it a bug?
Hi,
Here is a sample code implementation of what I consider as being a bug in
g++. Both g++ 4.1.1 and 4.2.2 have the same behaviour about this.
There is two lines which should do the same, but only one of the two works.
thanks
Patrick Lacasse
#include <iostream>
#include <typeinfo>
template< typename X >
struct A
{
typedef X X_type;
};
template< typename X >
void function( A<X> a,
//typename A<X>::X_type x ) // This line works. ( typedef workaround )
X x ) // This line doesn't work.
{
std::cout << "function(A<" << typeid(X).name() << ">," << x << ")" << std::endl;
}
int main()
{
// This call works with and without the typedef workaround.
function( A<double>(), 3.0 );
// Implicit conversion from int to double
// will only occurs with the typedef workaround.
function( A<double>(), 3 );
}