This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ RFC/Patch] PR 34938
- From: Jason Merrill <jason at redhat dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 22 Aug 2014 14:17:48 -0400
- Subject: Re: [C++ RFC/Patch] PR 34938
- Authentication-results: sourceware.org; auth=none
- References: <53F78398 dot 2000908 at oracle dot com>
On 08/22/2014 01:53 PM, Paolo Carlini wrote:
maybe this old issue is already fixed. We used to ICE on:
typedef void (*fptr)() __attribute((noreturn));
template<int> void foo();
template<fptr> void bar();
fptr f = bar< foo<0> >;
but lately we simply reject it:
34938.C:5:10: error: no matches converting function âbarâ to type âfptr
{aka void (*)() volatile}â
fptr f = bar< foo<0> >;
^
34938.C:3:21: note: candidate is: template<void (* <anonymous>)()
volatile> void bar()
template<fptr> void bar();
^
is that Ok? clang behaves like us, EDG accepts the code.
Well, since the attribute is outside the language, I guess we get to
decide what it means; C++11 [[noreturn]] is only defined on decls, not
types.
I think rejecting it makes sense; since bar is not declared as noreturn,
assigning its address to a noreturn function pointer seems wrong.
A secondary
issue I noticed is that we print 'volatile' instead of the attribute,
that is fixed by the patchlet below.
Currently function-cv-quals on a FUNCTION_TYPE used as a typedef or
template parameter have the same encoding as the const and noreturn
attributes; to get the printing right you need to know the context of
the FUNCTION_TYPE. If it's the type of a pointer, then the attribute is
correct.
Jason