http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45114

--- Comment #10 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 
2011-10-31 16:06:41 UTC ---
using the patch of comment 8
in the example below I get

$ c++ -std=gnu++0x -c talias.cc 
$ c++ -std=gnu++0x -c talias.cc -DALIAS
talias.cc: In instantiation of ‘Bar::D<T> Bar::d() [with T = int]’:
talias.cc:44:19:   required from here
talias.cc:34:23: error: no matching function for call to
‘Bar::D<int>::D(Bar::A<int>)’
talias.cc:34:23: note: candidates are:
talias.cc:19:5: note: Bar::D<T>::D(const Bar::A<T>&) [with T = int; Bar::A<T> =
Foo<int>]
talias.cc:19:5: note:   no known conversion for argument 1 from ‘Bar::A<int>
{aka Foo<int>}’ to ‘Bar::A<int>& {aka Foo<int>&}’
talias.cc:15:5: note: Bar::D<T>::D() [with T = int]
talias.cc:15:5: note:   candidate expects 0 arguments, 1 provided
talias.cc:14:10: note: constexpr Bar::D<int>::D(const Bar::D<int>&)
talias.cc:14:10: note:   no known conversion for argument 1 from ‘Bar::A<int>
{aka Foo<int>}’ to ‘const Bar::D<int>&’
talias.cc:14:10: note: constexpr Bar::D<int>::D(Bar::D<int>&&)
talias.cc:14:10: note:   no known conversion for argument 1 from ‘Bar::A<int>
{aka Foo<int>}’ to ‘Bar::D<int>&&’

otherwise the patch looks fine (i.e. no other problem found so far :-)

template<typename T>
struct Foo {
  explicit Foo(char *im) : m(im){}
  char * m;
};

struct Bar {

  template<typename T> using A = Foo<T>;

  template<typename T>
  struct D {
    D() {}
#ifndef ALIAS
    D(Foo<T> const & ia) : a(ia) {}
#else
    D(A<T>   const & ia) : a(ia) {}
#endif
    A<T>  a;
  };

  template<typename T>
  A<T> 
  a() {
    return  A<T>(m_i);
  }

  template<typename T>
  D<T> d() {
    return D<T>(a<T>());
  }

  char m_i[10000];
};


Bar b;
Bar::D<int> bar() {
  return b.d<int>();
}

Reply via email to