This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

c6000 compiler 7.4.x compiles despite inaccessible elided copy constructor

Hi

This bit me today, when I realized that I had written a bit of code that shouldn't compile, but did.

Consider the following program:

class Copyable
{
};

class NonCopyable
{
		NonCopyable(const NonCopyable&) {}
		NonCopyable& operator= (const NonCopyable&) { return *this; }
	public:
		NonCopyable() {}
		NonCopyable(const Copyable&) {}
		NonCopyable& operator= (const Copyable&) { return *this; }
		Copyable move() { return Copyable(); }
};

Copyable function(NonCopyable nc) { return nc.move(); }

int main()
{
	NonCopyable nc1;
	NonCopyable nc2( function( nc1.move() ) );
}

For this program, the 7.4.x C6000 compiler correctly complains that

"../temporary.cpp", line 21: error #694-D: "NonCopyable::NonCopyable(const NonCopyable &)", required for copy that was eliminated, is inaccessible

However, if I use a non-copyable base class (like boost::noncopyable), i.e.

class NonCopyableBase
{
		NonCopyableBase(const NonCopyableBase&) {}
		NonCopyableBase& operator= (const NonCopyableBase&) { return *this; }
	protected:
		NonCopyableBase() {}
};

class Copyable
{
};

class NonCopyable : private NonCopyableBase
{
	public:
		NonCopyable() {}
		NonCopyable(const Copyable&) {}
		NonCopyable& operator= (const Copyable&) { return *this; }
		Copyable move() { return Copyable(); }
};

Copyable function(NonCopyable nc) { return nc.move(); }

int main()
{
	NonCopyable nc1;
	NonCopyable nc2( function( nc1.move() ) );
}

then the code is compiled without any warning or error. The 8.x branch behaves differently and correctly complains in both cases.

The compiler flags were

-mv6400 --abi=coffabi -O3 -ms3 --strict_ansi --rtti


Unless I'm wrong and a diagnostic isn't required, is there any chance that this will be fixed in a future release of the 7.4.x branch (at least with --strict_ansi)?

Markus

  • Thank you for informing us about this problem, and submitting a well formed test case.  I can reproduce the problem behavior.  I filed SDSCM00051730 in the SDOWP system to have this investigated.  Feel free to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George