This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79318] conversion member function preceded with & is not marked as error
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 01 Feb 2017 09:25:30 +0000
- Subject: [Bug c++/79318] conversion member function preceded with & is not marked as error
- Auto-submitted: auto-generated
- References: <bug-79318-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79318
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Smaller testcase:
struct A
{
int a;
A () : a(0) {};
&operator int () { return a; };
};
int
bar ()
{
A a;
return a;
}
clang++ indeed reports:
pr79318.C:5:3: error: cannot specify any part of a return type in the
declaration of a conversion function; put the complete type after 'operator'
&operator int () { return a; };
^
&
[dcl.dcl]/12 indeed requires that conversion functions are declared with
nodeclspec-function-declaration.