This is the mail archive of the gcc-bugs@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]

strange thing with template evaluation


Maybe it is a bug, but maybe it is a feature.
At least one compiler does the job (CenterLine-C++ on Sun Ultra 1)

And after thinking on it for a while, I believe it SHOULD compile,
so please take a look at this cooked-down example and give me a hint
whether I am wrong or the compiler.

Btw.: Thanks for Your efforts in providing a free C++-Compiler.

> g++ --version
egcs-2.91.66
> g++ t_egcs.C
t_egcs.C: In function `int main()':
t_egcs.C:21: conversion from `C1<C2> ()(C2 (*)())' to non-scalar type `C1<C2>'
requested

???????????????????????????????????

     1  #include <iostream.h>
     2
     3  template <class A>
     4  class C1 {
     5  public:
     6    C1(const A d) { };
     7    //defining a copy ctor did not fix the problem
     8    //C1(C1<A> const& X) : m_d(X.m_d) {};
     9    C1(A *d) { };
    10    A m_d;
    11  };
    12
    13  class C2 { public: C2(void) { };};
    14
    15  int main()
    16  {
    17      C2  c2;
    18      C1<C2>  c1(C2());
    19      C1<C2>  c3(c2);
    20
    21      C1<C2>  c0=c1;
    22
    23   //   cout << c1.m_d << endl;
    24
    25
    26      return 0;
    27  }




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