On 28 Mrz., 11:05, Alex Vinokur wrote:
> On Mar 28, 10:24 am, Alex Vinokur wrote:
>
> > While compiling program below, behavior of g++ differs from Intel and
> > aCC HP compilers.
> > g++ detects error.
>
> > Any suggestions?

Yes: Write legal C++ code.

If you want a function to return an object of your class by value, you
better make this class at least movable. The other compilers probably
complain because they simply don't care and just apply copy elision.
However, the standard requires the class to be at least movable (C+
+2011) or copyable (C++2003) regardless of wether a compiler does RVO
or not (RVO = return value optimization).

> The same problem with simpler program.
>
> class noncopyable
> {
>    protected:
>       noncopyable() {}
>       ~noncopyable() {}
>    private:
>       noncopyable( const noncopyable& );
>       const noncopyable& operator=( const noncopyable& );
> };
>
> class Foo : private noncopyable
> {
>         public:
>         Foo (){}
> };
>
> Foo func1()
> {
>         return Foo();
> }
>
> [...]

Cheers!
SG
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
https://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to