Topic: empty base and copy assignment


Author: Vesa A J Karvonen <vkarvone@cc.helsinki.fi>
Date: 1999/08/28
Raw View
Hi,

consider the following program:

#include <iostream>
using namespace std;

struct E {};
struct F : E {char c;};

int main() {
  F f0;
  F f1;

  f0.c = '0';
  f1.c = '1';

  E& e0 = f0;
  E& e1 = f1;

  cout << f0.c << '\n';

  e0 = e1;

  cout << f0.c << '\n';

  return 0;
}

My questions:

Is the behaviour of the program defined by the standard (i.e. not
undefined or implementation defined)?

If so, then what is the correct behaviour (i.e. should it output 0 0 or 0
1)?

If not, then which clauses in the standard indicate that the behaviour is
undefined or implementation defined?

---
Vesa Karvonen
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]