I've had to resurrect an older C++ program which built on top of some
public matrix code (LinAlg). It was compiling properly two or three
years ago (so CW8 or perhaps CW7). Now, with my current CW9.6 setup,
I'm getting "illegal access" compile errors. The LinAlg library sets
up something like this:
class ElementWiseConst
{
friend class ElementWise;
friend class ElementWiseStrideConst;
friend class ElementWiseStride;
void operator=(const ElementWiseConst&);
// is not implemented, ergo, is not allowed
ElementWiseConst(const ElementWiseConst&);// Cloning is not allowed,
either
....
public:
// No public constructors...
// ElementWiseConst(Matrix& m) would be
// implicitly called
friend inline ElementWiseConst of_every(const Matrix& m) { return m;
}
friend inline ElementWiseConst of_every(const Matrix::ConstReference&
m)
{ return m.ref(); }
....
}
Later on, a function goes like this:
double e2_norm(const Matrix& m1, const Matrix& m2)
{
return of_every(m1).sum_squares(of_every(m2));
}
and the compiler now complains
Error : illegal access from 'ElementWiseConst' to protected/private
member 'ElementWiseConst::ElementWiseConst(const ElementWiseConst &)'
return of_every(m1).sum_squares(of_every(m2));
It seems somehow that the CW9 compiler is trying to access the
ElementWiseConst constructor, which has been disabled in the private
section of the declaration ("Cloning not allowed" comment). I'm not
sure if CW9 is somehow trying to instantiate an object when it wasn't
before, or if it has something to do with the "friend" declaration on
"of_every()", or what. I'll have to dig out my C++ reference books and
start figuring out all the details of constructors/friends/etc., but I
was wondering if anyone knows if CW9 tightened up on this sort of
parsing? I'm getting similar errors with my own derived cl*****, but
the above example is within LinAlg's code, which supposedly compiled
under "gcc 2.95.3 and gcc 3.2.1", as well as giving me no previous
problems with CW7/8.
Thanks,
David Oberst, NWT Bureau of Statistics
Yellowknife, NWT, Canada


|