Bug with null pointer to member as template argument

David Mazieres dm@reeducation-labor.lcs.mit.edu
Wed Dec 16 13:48:00 GMT 1998


Using "gcc version egcs-2.92.23 19981125 (gcc2 ss-980609
experimental)" and earlier, egcs rejects the following C++ program:

  template<class T, int T::*field> struct list {};
  
  struct foo {
    int x;
    list<foo, 0> subfoos;
  };

giving the error:

  voidmp.C:5: could not convert template argument `0' to `int foo::*'
  voidmp.C:5: warning: ANSI C++ forbids declaration `subfoos' with no type

I searched through the standard, and can't find any reason the program
should be rejected.  Certainly 0 is a valid pointer to member, and
there doesn't seem to be anything prohibiting the null value as a
template argument of type pointer to member.  The g++ 2.8.1 and KAI
KCC compilers also both accept the program.  Thus, this seems like an
egcs bug.

Thanks,
David



More information about the Gcc-bugs mailing list