is it a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux