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

Re: Overload resolution compilation error


Rodolfo Schulz de Lima wrote
> Ling-hua Tseng escreveu:
> > Obviously, {1, 2, 4, 5, 6, 7} are not matched.
> > Maybe you think that the item 3 is matched.
> > Unfortunately, it stands for the non-template functions.
> 
> Are you sure that it doesn't include template functions? Because I think 
> it makes sense to consider them too (as Visual Studio does). The point 
> is that non template functions arguments have higher priority than 
> template functions (as specified in paragraph 4), and IMO there's no 
> reason to differentiate between template and non-template functions' 
> argument target, making the latter work and the former not.
Even if the they are accepted, we still have a problem.
The target type is `F',
and it cannot be deduced by template argument deduction mechanism
since this mechanism need to know the type of `&print' for deducing.
Nevertheless, the overload resoluion mechanism need to know what `F' is.

Of course, the C++ standard didn't allow this infinite loop.
The template argument deduction should be done first (maybe succeeded or failed).
It's described in paragraph 2 of section 13.4 and section 14.8.8.2.

The template argument deduction is failed in GCC,
since I cannot find the following context in <file>.cxx.003t.original
after removing the two lines `call(&print<5>);' and `call(&print<7,6>);'
from your original example:
==========
  ;; Function void call(F) [with F = void (*)()] (_Z4callIPFvvEEvT_)
  ;; enabled by -tree-original

  <<cleanup_point <<< Unknown tree: expr_stmt
    f () >>>
  >>;
==========

Since the target type cannot be deduced by template argument deduction mechanism,
the overload resolution mechanism will not able to select any function names.
It's why I said the overload set is empty.

However, I have tested your example by Comeau C++ compiler in strict C++03 mode.
It's passed to compile without any problems,
so I guess that perhaps you're right.

I'll stop discussing the topic after this reply
since it will be moved to comp.std.c++ after moderator approving it.
I hope that we will able to get a good answer there.


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