This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79318] conversion member function preceded with & is not marked as error


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]