Original Post
The following code compiles without errors under Visual Studio 2005 Is the compiler allowed to optimize away the call to the copy constructor while calling the copy constructor is illegal?
class NoCopy
{
private:
NoCopy(const NoCopy&);
protected:
NoCopy() {}
~NoCopy() {}
};
class Foo : private NoCopy
{
public:
Foo(int) {}
~Foo() {}
};
int main()
{
Foo f(Foo(42));
}