[cfe-dev] Template matching question

Richard Smith richard at metafoo.co.uk
Thu Feb 20 11:59:12 PST 2014


This:

struct SomeType {};
template<typename T> void deduce(T (*)(), ...) {}
template<typename T> void deduce(T f, SomeType g) {}
void foo() { throw SomeType(); }
void bar() { deduce( foo ); }

... works fine on Clang 3.2 and on Clang trunk.


On Thu, Feb 20, 2014 at 10:18 AM, David Blaikie <dblaikie at gmail.com> wrote:

> Could you provide a standalone example of the problem? And include a log
> showing the file contents, the compiler version, the full command used to
> compile the source as well as all the output (error messages, etc)?
>
> My attempts to reproduce this with ToT Clang seem to have failed -
> something similar to what you described compiles without error.
>
>
> On Thu, Feb 20, 2014 at 8:19 AM, Michael Steinberg <
> michael.steinberg at tu-clausthal.de> wrote:
>
>> Hello,
>> there is an interesting (for me) problem with luabind that you might be
>> able to answer.
>>
>> Considering the template:
>>
>> template< typename T >
>> void deduce( T (*)(), ... ) {}
>>
>> template< typename T >
>> void deduce( T f, SomeType g ) {}
>>
>> ...more overloads...
>>
>> and the function:
>>
>> void foo() {
>>    throw some();
>> }
>>
>> deduce( foo );
>>
>> clang 3.2 seems to add an implicit attribute "noreturn" (I assume that
>> is because clang detected the function will never return). This
>> attribute seems to rule out the given first overload of function
>> template "deduce", which would otherwise be responsible to match the
>> given function's signature and consequently fails on the second
>> overload. Is that legal? Or maybe the mismatch is caused by another
>> reason?
>>
>> Kind regards,
>> Michael
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140220/eef33337/attachment.html>


More information about the cfe-dev mailing list