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]
Other format: [Raw text]

[Bug c++/15674] [DR214] template argument binding differs between member and static fumctions


------- Additional Comments From nathan at gcc dot gnu dot org  2005-06-06 12:35 -------
Closing this, it is not a bug.  What special cases the structure member example
is that one of the function is a template and the other is not.  Thus overload
resolution picks the non-template (all other things being equal).  Template
specialization ordering never gets a look in.

If you try a completely non-templated example of
  void Foo (int *);
  void Foo (int (&)[5]);
you'll discover overload resolution considers this ambiguous.  The lvalue
array->pointer transform being ignored in ranking the conversion sequences
(13.3.3.2]/3.

The case with both being template instantiations is the same wrt ranking the
conversion sequences, and template partial specialization does not get to
overrule that.

This leaves the members of S<int>, the pointer version
   void S(T *);
although it uses a template parameter, is not a template function in its own
right (it has no template header), so in the context of an instantiation of S,
it is not a template.  The other template
  template <unsigned n> void S(T (&)[n])
though, is a template in its own right, and will defer to the other function in
overload resolution.

If you want to distinguish these functions, make the pointer one a reference to
pointer in both the non-template and template cases,


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


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


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