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]

template member function not compiled



Hi all,

the following example will not compile with gcc version 2.95.2,
under linux and solaris 2.6. 
As far as I know, it should be supported by c++. It compiles under KCC.

more precisely:

g++ -D BUG_ test.C

gives:

test.C: In function `bool tt<false>(int)':
test.C:29:   instantiated from here
test.C:21: invalid operands `{unknown type}' and `int' to binary `operator <'
test.C: In function `bool tt<true>(int)':
test.C:30:   instantiated from here
test.C:21: invalid operands `{unknown type}' and `int' to binary `operator <'


g++ test.C

does not encounter the difficulty

-------------------------------------CODE:
#include <iostream.h>

class test {
  int memb;

public:
  test() : memb(0) {};

  template <bool detection>
  bool is( int i ) const {

    return memb==(i+detection);
  };
};

template <bool detect>
bool tt( int s ) {

  test t;
  return t.is<0>(s);
}

main() {

  test t2;
  cout << t2.is<0>(3);
#ifdef BUG_
  cout << tt<0>(2);
#endif
};
------------------------------------------

This problem appeared in a real size program.
Avoiding it makes the code really messy and impairs performance.

So, I hope you can fix it soon :)


Best regards,


Pierre-Alain Genilloud
Institut for theoretical Physics
ETH-Hoenggerberg
8093 Zuerich
Switzerland

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