[Bug c++/28365] New: error: ' error: 'MyClass::MyClass(const MyClass&)' is private error: within this context

2006-07-12 Thread kk at microfocus dot com
class MyClass
{
public:
 MyClass() {}
 MyClass(int i) { m_i = i;}
private:
 MyClass(const MyClass& x) {};
 int m_i;
};
class MyInserter
{
public:
 MyInserter() {};
 MyInserter& operator<<(const MyClass& m) {m_c = m; return *this;};
private:
 MyClass m_c;
};

int main()
{
 MyClass a(1);
 MyInserter m;
 m << a;
 m << MyClass(2);

 return 0;
}


In this case a new MyClass  node is not suppose to be constructed so a
constructor should not be needed. This works on gcc 3.2 does not work on 4.1.1

RogueWave has this throughout it's code.


-- 
   Summary: error: ' error: 'MyClass::MyClass(const MyClass&)'
is private   error: within this context
   Product: gcc
   Version: 4.1.1
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kk at microfocus dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28365



[Bug c++/28365] error: ' error: 'MyClass::MyClass(const MyClass&)' is private error: within this context

2006-07-13 Thread kk at microfocus dot com


--- Comment #3 from kk at microfocus dot com  2006-07-13 21:49 ---
(In reply to comment #2)
> If it is in our (Rogue Wave) current code, could you please let us know where
> so we can look into fixing it? (It's doesn't matter whther gcc does the right
> thing here or not, our code should be portable either way.) Thanks!

OK, here goes. This is what I'm getting. If you guys do have a fix let me know.
You have an operator overload for the Expr but it really can't be used in this
case cause the const constructor is private. 

By the way I'm trying to build this on an AIX 5.3 machine with the GNU C++ 
This really limits me to the gcc 4.0.0 or 4.1.1 compiler. 


expr.h:248: error: 'RWDBBoundExpr::RWDBBoundExpr(const RWDBBoundExpr&)' is
private
source/sr_hfd.cpp:397: error: within this context
RW/workspaces/LINUX/GNUC/rw/db/expr.h:248: error:
'RWDBBoundExpr::RWDBBoundExpr(const RWDBBoundExpr&)' is private
source/sr_hfd.cpp:398: error: within this context
RW/workspaces/LINUX/GNUC/rw/db/expr.h:248: error:
'RWDBBoundExpr::RWDBBoundExpr(const RWDBBoundExpr&)' is private


Operator is being overloaded:

inserter.h:  RWDBInserter&  operator<<( const RWDBExpr& expr );
select.h:RWDBSelector&  operator<<(const RWDBExpr& expr);

expr.h:

  private:
RWDBBoundExpr(const RWDBBoundExpr&);
RWDBBoundExpr& operator=(const RWDBBoundExpr&);


Here is our code segment:

m_ins = m_table.inserter(schema);

m_ins << RWDBBoundExpr(&m_v_scnid)
  << RWDBBoundExpr(&m_v_id)
  << RWDBBoundExpr(&m_v_row)
  << RWDBBoundExpr(&m_v_col)
  << RWDBBoundExpr(&m_v_attr)
  << RWDBBoundExpr(&m_v_color)
  << RWDBBoundExpr(&m_v_highlight)
  << RWDBBoundExpr(&m_v_hashind)
  << RWDBBoundExpr(&m_v_maxlen)
  << RWDBBoundExpr(&m_v_value);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28365