[cfe-dev] Noreturn adjustment for template functions

Alexander Zinenko ftynse at gmail.com
Sun Feb 17 01:53:35 PST 2013


This is now PR15291. Thanks.


On 17 February 2013 03:23, John McCall <rjmccall at apple.com> wrote:

> On Feb 16, 2013, at 5:18 AM, Alexander Zinenko <ftynse at gmail.com> wrote:
> > +Richard Smith
> >
> > Investigating another issue, I found out that an instantiated noreturn
> template function can't be implicitly used as not-noreturn argument while
> non-template function can.
> > Here is an example:
> >
> > void __attribute__((noreturn)) func(int i) {}
> >
> > template <typename T>
> > void __attribute__((noreturn)) tfunc(T t) {}
> >
> > typedef void (*ptr)(int);
> >
> > void foo(ptr p) {}
> >
> > void bar() {
> >   foo(func); // Okay
> >   foo(tfunc<int>); // Error: ... candidate function 'foo' not viable
> > }
> >
> > It is most likely due to noreturn function representation (there was a
> discussion on PR15105 lately). As far as I see, SemaOverload.cpp contains a
> special case for noreturn adjustment as an implicit conversion, but it
> doesn't account for templates.
> >
> > One would expect consistent behavior in this case, though.
> > Should I file a bug for it?
>
> Yes.  The problem is almost certainly that template argument deduction
> should permit an inexact match requiring a noreturn conversion in the same
> sorts of places that it would permit an inexact match requiring a
> qualification conversion.
>
> John.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130217/eab279d5/attachment.html>


More information about the cfe-dev mailing list