This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Tracking down why temp copies are made


I'm not sure how much of my program to post.

Below is a snippet of my class template. The NoCopy base hides the copy constructor.

template <class L, class OpTag, class R>
struct RightExpression : NoCopy
{
    RightExpression(RightExpression const &p) : l(p.l), r(p.r)
    {
	nothing2(__LINE__);
    }
   ...

    L const&l;
    R const&r;
};

If I take out the copy constructor in the class, the program fails to compile:

./NoCopy.H:9: error: 'NoCopy::NoCopy(const NoCopy&)' is private
RightExpression.H:27: error: within this context

If I put the copy constructor in, it compiles but nothing2 never gets called. I also tried this same thing with a print statement and the print statement never comes out.

I'm calling g++ as simple as possible: g++ -I. -c -o temp.o temp.C

I get the same behavior on 4.0.1 and 4.0.2. I do *not* get this with I use IBM's xlC -- but, looking at the assembly code, it is doing as much work for some reason.

Any ideas of how to track this down?

Thanks,
Perry Smith
Ease Software, Inc.
pedz@easesoftware.com
http://www.easesoftware.com

Low cost SATA Products for IBMs p5, pSeries, and RS/6000 AIX systems




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]