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

gcc at mailinator dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 1 07:44:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79318

--- Comment #1 from John Simon <gcc at mailinator dot com> ---
Full example:

#include <iostream>

using namespace std;


class Foo
{
  private:
    int a;
  public:
    Foo():a(0){};
    &operator int() {return a;};  // this fails with Clang    
};


int main()
{
  Foo foo;

  int x = foo;

  cout << x << endl;  

}


More information about the Gcc-bugs mailing list