Bug with null pointer to member as template argument

Mark Mitchell mark@markmitchell.com
Wed Dec 16 16:13:00 GMT 1998


>>>>> "David" == David Mazieres <dm@reeducation-labor.lcs.mit.edu> writes:

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

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

    David> giving the error:

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

    David> I searched through the standard, and can't find any reason
    David> the program should be rejected.  Certainly 0 is a valid

You missed:

  A template-argument for a non-type, non-template
       template-parameter shall be one of:

       ... 

       --a pointer to member expressed as described in _expr.unary.op_. 

which says that you must write `&C::f' for some choice of `C' and
`f'.  Also:

 For a non-type template-parameter of type pointer to member
	   function, no conversions apply.


-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com



More information about the Gcc-bugs mailing list