Bug 16145 - Complaint about private copy constructor
Summary: Complaint about private copy constructor
Status: RESOLVED DUPLICATE of bug 12226
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-22 20:11 UTC by apl
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Simple test of private copy constructor (285 bytes, text/plain)
2004-06-22 20:12 UTC, apl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description apl 2004-06-22 20:11:08 UTC
Prior to 3.4, a private copy constructor works just fine.  In 3.4.1, it seems
that a simple example as below will fail with a message:

gccbug.cxx: In function `int main()':
gccbug.cxx:17: error: `Simple::Simple(const Simple&)' is private
gccbug.cxx:32: error: within this context

 
class Simple {
public:
  Simple (int i) : m_i (i) {} 
  int m_i;
private:
  Simple (const Simple&);       // hide this
};

std::ostream & operator<< (std::ostream & f, const Simple & s)
{
  f << s.m_i;

  return f;
}


I have a variation on this test that has a public copy constructor that asserts
if it's called.  The test program never calls the copy constructor.

Is this a change in the language or a bug?
Comment 1 apl 2004-06-22 20:12:40 UTC
Created attachment 6607 [details]
Simple test of private copy constructor

compile with -DTESTER to demonstrate that copy constructor is never called

compile without any flags to see private copy constructor warning message.
Comment 2 Wolfgang Bangerth 2004-06-22 20:29:16 UTC
That's what the language requires. See the release notes of gcc 3.4.0. 
 
W. 
Comment 3 Andrew Pinski 2004-08-27 08:50:22 UTC
Reopening to mark as a dup of ...
Comment 4 Andrew Pinski 2004-08-27 08:50:44 UTC
bug 12226.

*** This bug has been marked as a duplicate of 12226 ***