g++-3.0 copies constructors
>Submitter-Id: net
>Originator: Jaakko Niemi <liiwi@iki.fi>
>Organization: The Debian project
>Confidential: no
>Synopsis: g++-3.0 copies constructors
>Severity: serious
>Priority: medium
>Category: c++
>Class: sw-bug
>Release: 3.0 (Debian GNU/Linux)
>Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: i686
host: i386-linux
build: i386-linux
target: i386-linux
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #103980.
Please CC 103980-quiet@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/103980
sfs report: http://www.mit.edu:8008/snafu.fooworld.org/sfs/116
]
SFS (secure file system) fails to compile with gcc 3.0, and it was
tracked down to this example code that reproduces the error:
-------------
class aios {
friend class aiosout;
public:
aios ();
~aios ();
};
class aiosout {
aiosout (const aiosout &o);
aiosout &operator= (const aiosout &);
public:
aiosout (aios &a) {}
~aiosout () {}
};
template<class T> inline const aiosout&
operator<< (const aiosout &o, const T &a)
{
return o;
}
void fault(void)
{
aios a;
// normally a C++ compiler should resolve the following like this:
// tmp = aiosout(a)
// operator<< (tmp, 10);
// apparently, g++ 3.0 tries to do something like this:
// tmp1 = aiosout(a)
// tmp2 = aiosout(tmp1) <== copy constructor (unusable!)
// operator<< (tmp2, 10);
// which is wasteful even when it works... maybe now we know why
a << 10;
}
-----
>How-To-Repeat:
>Fix:
Reply to: