[Bug c++/79318] conversion member function preceded with & is not marked as error
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 1 09:25:00 GMT 2017
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.
More information about the Gcc-bugs
mailing list