fork download
  1. struct Foo
  2. {
  3. int Bar;
  4. Foo& operator= (int Rhs)
  5. {
  6. this->Bar = Rhs;
  7. return *this;
  8. }
  9. };
  10. const Foo F()
  11. {
  12. return Foo();
  13. }
  14. int main()
  15. {
  16. F() = 42;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:16:6: error: passing ‘const Foo’ as ‘this’ argument of ‘Foo& Foo::operator=(int)’ discards qualifiers [-fpermissive]
  F() = 42;
      ^
stdout
Standard output is empty