fork download
  1. struct T {
  2. int m_x;
  3. T(int x) : m_x(x) {}
  4.  
  5. operator T() {
  6. return T(0);
  7. }
  8. };
  9.  
  10. int main() {
  11. volatile T v(2);
  12.  
  13. T nv(1);
  14. nv = v; // nv.m_x = 0
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:10: error: no match for ‘operator=’ in ‘nv = v’
prog.cpp:14:10: note: candidates are:
prog.cpp:1:8: note: T& T::operator=(const T&)
prog.cpp:1:8: note:   no known conversion for argument 1 from ‘volatile T’ to ‘const T&’
prog.cpp:1:8: note: T& T::operator=(T&&)
prog.cpp:1:8: note:   no known conversion for argument 1 from ‘volatile T’ to ‘T&&’
stdout
Standard output is empty