help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ behavior while noncopyable class


From: Alex Vinokur
Subject: Re: g++ behavior while noncopyable class
Date: Wed, 28 Mar 2012 02:05:07 -0700 (PDT)
User-agent: G2/1.0

On Mar 28, 10:24 am, Alex Vinokur <alex.vino...@gmail.com> wrote:
> Hi,
>
> While compiling program below, behavior of g++ differs from Intel and
> aCC HP compilers.
> g++ detects error.
>
> Any suggestions?
>

The same problem with simpler program.

// ============================
// File test2.cpp
// --------------
class noncopyable
{
   protected:
      noncopyable() {}
      ~noncopyable() {}
   private:
      noncopyable( const noncopyable& );
      const noncopyable& operator=( const noncopyable& );
};

// --------------
class Foo : private noncopyable
{
        public:
        Foo (){}
};

// -------------
static Foo func1()
{
        return Foo();
}

// --------------
int main()
{
        return 0;
}
// =============================


-------------------------
Compilers:

Intel compiler:
> icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on
Intel(R) 64, Version 12.0.4.191 Build 20110427
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

aCC HP compiler:
> aCC -V
aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]


GNU g++ compiler:
> g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
enable-checking=release --with-system-zlib --enable-__cxa_atexit --
disable-libunwind-exceptions --enable-libgcj-multifile --enable-
languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --
disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-
gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)


-------------------------
Compilation.


> icpc test2.cpp
// No errors

> aCC test2.cpp
// No errors

> g++ test2.cpp
test2.cpp: In copy constructor Foo::Foo(const Foo&):
test2.cpp:11: error: noncopyable::noncopyable(const noncopyable&) is
private
test2.cpp:17: error: within this context
test2.cpp: In function Foo func1():
test2.cpp:25: note: synthesized method Foo::Foo(const Foo&) first
required here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]