This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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 );
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]