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

Re: (C++) Patch to rework use of instantiate_type



    Jason> Mark, please take a look at the pt.c changes; I couldn't
    Jason> tell why the code was the way it was, and my changes don't
    Jason> break anything, but maybe you had a secret plan?  :)

I did.

Note the comment above convert_nontype_argument:

/* Attempt to convert the non-type template parameter EXPR to the
   indicated TYPE.  If the conversion is successful, return the
   converted value.  If the conversion is unsuccesful, return
   NULL_TREE if we issued an error message, or error_mark_node if we
   did not.  We issue error messages for out-and-out bad template
   parameters, but not simply because the conversion failed, since we
   might be just trying to do argument deduction. 

So, if we resolve an overloaded function and get a function with
internal linkage, we shouldn't complain; when trying a different
template, things might work out OK.  Consider:

  template <void (*F)(int)> void f();
  template <void (*F)(double)> void f();
  extern void g(double);

  void h ()
  {
    f<g>();
  }

This is legal, I think: we get the second `f'.  Your changes cause:

test2.C: In function `void h()':
test2.C:7: argument of type `void ()(double)' does not match `void ()(int)'

Similar comments apply to the fact that you #if 0'd out code that
deals with non-external-linkageness of references-to-functions.

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


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