[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 26 13:06:52 PDT 2022


ychen added a comment.

In D128745#3752148 <https://reviews.llvm.org/D128745#3752148>, @ychen wrote:

> In D128745#3751471 <https://reviews.llvm.org/D128745#3751471>, @joanahalili wrote:
>
>> We have some compilation failures on our end because of function template parameter deduction when passing the function template to a function pointer.
>>
>>   typedef void (*f)(const int&);
>>   
>>   template <typename T>
>>   void F(T value) {}
>>   
>>   template <typename T>
>>   void F(const T& value){}
>>   
>>   void q(f);
>>   
>>   void w() {
>>       q(&F);
>>   }
>>
>> https://gcc.godbolt.org/z/faoq74q7G
>> Is this an intended outcome for this patch?
>
> Thanks for the report. No that's not the intent. This should only affect partial ordering but not which candidate is viable (error message `candidate function not viable ...`). I'll take a look.

This new behavior is correct. It is due to the change on line 1758 in `SemaTemplateDeduction.cpp`. Basically, both the taking address of and regular function call to the overloaded function set using the same partial ordering rule (Relevant wording https://eel.is/c++draft/over.over#5). GCC was inconsistent in this regard (https://gcc.godbolt.org/z/WrKsaKrdz). MSVC agrees with this new/correct behavior.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128745/new/

https://reviews.llvm.org/D128745



More information about the cfe-commits mailing list