[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
g++ behavior while noncopyable class
From: |
Alex Vinokur |
Subject: |
g++ behavior while noncopyable class |
Date: |
Wed, 28 Mar 2012 01:24:14 -0700 (PDT) |
User-agent: |
G2/1.0 |
Hi,
While compiling program below, behavior of g++ differs from Intel and
aCC HP compilers.
g++ detects error.
Any suggestions?
Thanks
// =====================================
// File test1.cpp
// --------------
class noncopyable
{
protected:
noncopyable() {}
~noncopyable() {}
private:
noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& );
};
// --------------
class Foo : public noncopyable
{
public:
Foo (const Foo& i_foo, int i_int)
{
}
static Foo func1(const Foo& i_foo, int i_int)
{
return Foo(i_foo, i_int);
}
};
// --------------
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 test1.cpp
// No errors
> aCC test1.cpp
// No errors
> g++ test1.cpp
test1.cpp: In copy constructor Foo::Foo(const Foo&):
test1.cpp:9: error: noncopyable::noncopyable(const noncopyable&) is
private
test1.cpp:15: error: within this context
test1.cpp: In static member function static Foo Foo::func1(const Foo&,
int):
test1.cpp:23: note: synthesized method Foo::Foo(const Foo&) first
required here